SMIL  1.0.4
skiz.py
1 from smilPython import *
2 
3 def tgdskiz(im1, im2, imMask):
4  tmp1 = Image(im1)
5  tmp2 = Image(im1)
6  sumIm = Image(im1)
7  vol0 = -1
8  vol1 = 0
9  while vol0<vol1:
10  dilate(im1, tmp1, se)
11  dilate(im2, tmp2, se)
12  addNoSat(tmp1, tmp2, sumIm)
13 
14 
15 
16 
17 def skizBin(label1, label2, maskIm, se=hSE()):
18  tmp1 = Image(label1)
19  tmp2 = Image(label1)
20  lpe = Image(label1)
21  oldVol = 0
22  newVol = -1
23  while oldVol != newVol:
24  dilate(label1, tmp1, se)
25  dilate(label2, tmp2, se)
26  addNoSat(label1, label2, lpe)
27  threshold(lpe, 0, 254, lpe)
28  inf(maskIm, lpe, lpe)
29  mask(tmp1, lpe, tmp1)
30  mask(tmp2, lpe, tmp2)
31  sup(label1, tmp1, label1)
32  sup(label2, tmp2, label2)
33 
34  oldVol = newVol
35  newVol = vol(label1)
36  print(newVol)
37  #raw_input()
38 
39 def trueWatershed(imIn, imMark, imOut, se=hSE()):
40  #global label1, label2, maskIm
41  label1 = Image(imIn)
42  label2 = Image(imIn)
43  maskIm = Image(imIn)
44  label1.showLabel()
45  label2.showLabel()
46  maskIm.show()
47 
48  label(imMark, label1)
49  mask(~label1, label1, label2)
50 
51  for i in range(rangeVal(imIn)[1]+1):
52  threshold(imIn, 0, i, maskIm)
53  sup(maskIm, imMark, maskIm)
54  skizBin(label1, label2, maskIm, se)
55 
56  copy(label1, imOut)
57 
58 
59 def skizIsotrop(imIn, imOut, se=hSE()):
60  label1 = Image(imIn)
61  label2 = Image(imIn)
62  maskIm = Image(imIn)
63  fill(maskIm, 255)
64 
65  label(imIn, label1)
66  mask(~label1, label1, label2)
67 
68  label1.showLabel()
69  label2.showLabel()
70  lpe.show()
71  tmp1.showLabel()
72  tmp2.showLabel()
73 
74  skizBin(label1, label2, maskIm, se)
75 
76 
RES_T sup(const Image< T > &imIn1, const Image< T > &imIn2, Image< T > &imOut)
sup() - Sup of two images
Definition: DImageArith.hpp:254
RES_T inf(const Image< T > &imIn1, const Image< T > &imIn2, Image< T > &imOut)
inf() - Inf of two images
Definition: DImageArith.hpp:305
RES_T addNoSat(const Image< T > &imIn1, const Image< T > &imIn2, Image< T > &imOut)
addNoSat() - Addition (without saturation check)
Definition: DImageArith.hpp:126
RES_T mask(const Image< T > &imIn, const Image< T > &imMask, Image< T > &imOut)
mask() - Image mask
Definition: DImageArith.hpp:1969
RES_T fill(Image< T > &imOut, const T &value)
fill() - Fill an image with a given value.
Definition: DImageArith.hpp:1456
RES_T threshold(const Image< T > &imIn, T minVal, T maxVal, T_out trueVal, T_out falseVal, Image< T_out > &imOut)
threshold() - Image threshold
Definition: DImageHistogram.hpp:269
size_t label(const Image< T1 > &imIn, Image< T2 > &imOut, const StrElt &se=DEFAULT_SE)
label() - Image labelization
Definition: DMorphoLabel.hpp:564
vector< T > rangeVal(const Image< T > &imIn, bool onlyNonZero=false)
rangeVal() - Min and Max values of an image
Definition: DMeasures.hpp:416
double vol(const Image< T > &imIn)
vol() - Volume of an image
Definition: DMeasures.hpp:129
RES_T dilate(const Image< T > &imIn, Image< T > &imOut, const StrElt &se=DEFAULT_SE, const T borderVal=ImDtTypes< T >::min())
dilate() - Morphological grayscale dilation
Definition: DMorphoBase.hpp:65
RES_T copy(const Image< T1 > &imIn, size_t startX, size_t startY, size_t startZ, size_t sizeX, size_t sizeY, size_t sizeZ, Image< T2 > &imOut, size_t outStartX=0, size_t outStartY=0, size_t outStartZ=0)
copy() - Copy image (or a zone) into an output image
Definition: DImageTransform.hpp:84