Skip to content

Commit

Permalink
addapted local filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ronshnapp committed Nov 1, 2024
1 parent f6c9e69 commit 7b43ab6
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 154 deletions.
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
October 31, 2024
November 1, 2024

Version: 1.1.1
Version: 1.1.2


<img src="./user_manual/figs/logo.png" style="zoom:20%;" />
Expand Down
37 changes: 24 additions & 13 deletions myptv/segmentation_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
contains a class for segmentation of circular particles
"""

from tracking_2D_mod import track_2D_multiframe
from myptv.tracking_2D_mod import track_2D_multiframe
from myptv.TsaiModel.camera import camera_Tsai
from myptv.tracking_mod import fill_in_trajectory

from numpy import ones, savetxt, meshgrid
from pandas import read_csv

from numpy import ones, savetxt, meshgrid, float32
from numpy import sum as npsum
from numpy import abs as npabs
from numpy import median as npmedian
from numpy import array
from numpy import append as npappend

from skimage.io import imread
from skimage import io
Expand Down Expand Up @@ -101,13 +106,23 @@ def __init__(self, image, sigma=None, threshold=10, mask=1.0,
def local_filter(self, image):
'''returns a new image where the local mean neighbourhood of
each pixel is subtracted.'''
w = self.loc_filter
window = ones((w, w)) / w**2
local_mean = convolve2d(image, window, mode='same')
new_im = image - local_mean
new_im[new_im<0] = 0
new_im = new_im.astype('uint8')
return new_im
# w = self.loc_filter
# window = ones((w, w)) / w**2
# local_mean = convolve2d(image, window, mode='same')
# new_im = image - local_mean
# new_im[new_im<0] = 0
# new_im = new_im.astype('uint8')

S = self.loc_filter
flt = image.astype(float32) #/ 255.0
blur = gaussian_filter(flt, S)
num = flt - blur

blur = gaussian_filter(num*num, S)
den = blur**0.5
normed = num / den

return image * (normed>1)



Expand Down Expand Up @@ -610,10 +625,6 @@ def save_results(self, fname):



from numpy import array
from numpy import append as npappend
from pandas import read_csv
from tracking_mod import fill_in_trajectory

class tracking_augmented_segmentation(track_2D_multiframe):

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
setup(
name='myptv',
packages=find_packages(include=['myptv', 'myptv.fibers', 'myptv.TsaiModel', 'myptv.extendedZolof', 'myptv.makePlots', 'myptv.sheets']),
version='1.1.1',
version='1.1.2',
description='A 3D Particle Tracking Velocimetry library',
install_requires=['numpy', 'scipy', 'scikit-image','pandas','matplotlib','pyyaml', 'tk', 'Pillow>=9.5.0'],
author='Ron Shnapp',
Expand Down
22 changes: 12 additions & 10 deletions user_manual/user_manual.aux
Original file line number Diff line number Diff line change
Expand Up @@ -97,31 +97,33 @@
\@writefile{toc}{\contentsline {subsubsection}{\numberline {3.3.1}How to segment in MyPTV}{14}{subsubsection.3.3.1}}
\@writefile{toc}{\contentsline {subsubsection}{\numberline {3.3.2}Two methods of segmentation}{14}{subsubsection.3.3.2}}
\citation{Bourgoin2020}
\@writefile{lof}{\contentsline {figure}{\numberline {9}{\ignorespaces The effect oft various image filters on the segmentation.\relax }}{15}{figure.caption.13}}
\newlabel{fig:image_filters}{{9}{15}{The effect oft various image filters on the segmentation.\relax }{figure.caption.13}{}}
\@writefile{lof}{\contentsline {figure}{\numberline {10}{\ignorespaces An example showing that segmentation using the dilation method can be very useful when segmenting large objects as it can resolve overlap issues.\relax }}{15}{figure.caption.14}}
\newlabel{fig:Labeling_vs_Dilation}{{10}{15}{An example showing that segmentation using the dilation method can be very useful when segmenting large objects as it can resolve overlap issues.\relax }{figure.caption.14}{}}
\@writefile{lof}{\contentsline {figure}{\numberline {9}{\ignorespaces An example showing that segmentation using the dilation method can be very useful when segmenting large objects as it can resolve overlap issues.\relax }}{15}{figure.caption.13}}
\newlabel{fig:Labeling_vs_Dilation}{{9}{15}{An example showing that segmentation using the dilation method can be very useful when segmenting large objects as it can resolve overlap issues.\relax }{figure.caption.13}{}}
\@writefile{toc}{\contentsline {subsubsection}{\numberline {3.3.3}Segmentation filters}{15}{subsubsection.3.3.3}}
\newlabel{sec:segment_filters}{{3.3.3}{15}{Segmentation filters}{subsubsection.3.3.3}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {3.4}Matching}{15}{subsection.3.4}}
\newlabel{sec:workflow_match}{{3.4}{15}{Matching}{subsection.3.4}{}}
\citation{Ouellette2006}
\citation{Luthi2005}
\citation{Xu2008}
\@writefile{lof}{\contentsline {figure}{\numberline {10}{\ignorespaces The effect oft various image filters on the segmentation.\relax }}{16}{figure.caption.14}}
\newlabel{fig:image_filters}{{10}{16}{The effect oft various image filters on the segmentation.\relax }{figure.caption.14}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {3.5}Tracking}{16}{subsection.3.5}}
\newlabel{sec:workflow_track}{{3.5}{16}{Tracking}{subsection.3.5}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {3.6}Calibration with particles}{16}{subsection.3.6}}
\newlabel{sec:workflow_calibration_with_particles}{{3.6}{16}{Calibration with particles}{subsection.3.6}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {3.7}Smoothing}{16}{subsection.3.7}}
\newlabel{sec:workflow_smooth}{{3.7}{16}{Smoothing}{subsection.3.7}{}}
\citation{Luthi2005}
\citation{Xu2008}
\@writefile{lof}{\contentsline {figure}{\numberline {11}{\ignorespaces An example for experimental setup for 2D tracking. Note that the camera doesn't have to be perpendicular to the particles' plane and that the particles don't have to be at $z=0$. \relax }}{17}{figure.caption.20}}
\newlabel{fig:2D_tracking}{{11}{17}{An example for experimental setup for 2D tracking. Note that the camera doesn't have to be perpendicular to the particles' plane and that the particles don't have to be at $z=0$. \relax }{figure.caption.20}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {3.7}Smoothing}{17}{subsection.3.7}}
\newlabel{sec:workflow_smooth}{{3.7}{17}{Smoothing}{subsection.3.7}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {3.8}Stitching}{17}{subsection.3.8}}
\newlabel{sec:workflow_stitch}{{3.8}{17}{Stitching}{subsection.3.8}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {3.9}2D tracking guide}{17}{subsection.3.9}}
\newlabel{sec:2D_tracking}{{3.9}{17}{2D tracking guide}{subsection.3.9}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {3.10}Manual Matching GUI}{17}{subsection.3.10}}
\newlabel{sec:man_match}{{3.10}{17}{Manual Matching GUI}{subsection.3.10}{}}
\citation{Shnapp2023}
\citation{Shnapp2023}
\@writefile{toc}{\contentsline {subsection}{\numberline {3.10}Manual Matching GUI}{18}{subsection.3.10}}
\newlabel{sec:man_match}{{3.10}{18}{Manual Matching GUI}{subsection.3.10}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {3.11}Fiber tracking}{18}{subsection.3.11}}
\newlabel{sec:fibers}{{3.11}{18}{Fiber tracking}{subsection.3.11}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {3.12}Plotting the results}{18}{subsection.3.12}}
Expand Down
Loading

0 comments on commit 7b43ab6

Please sign in to comment.