Mask smoothing after resizing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Mask smoothing after resizing

damien.schnebelen
Dear all,

I have stacks of binary images that correspond to segmentation masks. I want to increase the image size (scale) of each image in those stacks by a certain factor. When I do this I naturally obtain some steps in the boundaries due to the increase in resolution.

Is it possible to smooth the masks? Another way could be to fit the masks to a spline and scale the splines?

I would appreciate your tips on this matter. Thank you in advance.

My best,
Damien
Reply | Threaded
Open this post in threaded view
|

Re: Mask smoothing after resizing

Michael Schmid
On Jul 14, 2015, at 11:08, damien.schnebelen wrote:

> I have stacks of binary images that correspond to segmentation masks. I want
> to increase the image size (scale) of each image in those stacks by a
> certain factor. When I do this I naturally obtain some steps in the
> boundaries due to the increase in resolution.
>
> Is it possible to smooth the masks? Another way could be to fit the masks to
> a spline and scale the splines?

Hi Damien,

there are two possiblities that come into my mind:

(1) Image>Adjust>Size with bilinear interpolation, then threshold at half brightness (0-127) to get a binary image again.

(2) If you have one object per image, enlarge the canvas size (with top left fixed). Then, for each slice in the stack run Edit>Selection>Create Selection, Edit>Selection>Fit Spline, Edit>Selection>Scale (without the 'centered' option). If there can be more than one object per image, add them to the Roi Manager via 'Analyze Particles', and loop over the Rois doing this. this approach might be a bit tricky.

Method (2) will usually give you somewhat better quality.

Michael

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Mask smoothing after resizing

damien.schnebelen
Thank you for this quick reply ! Indeed the second method allow me to get a clearer contour, and so I will use it now.

Thank you again,
Damien
Reply | Threaded
Open this post in threaded view
|

Re: Mask smoothing after resizing

damien.schnebelen
Dear all,

I have another question concerning the smoothing. The method enounced above works correctly when I do it by hand, but when I have scripted it in Python, the results are not the same.
I've take a look at the java code for the manual function (using Command Finders -> Fit Splines -> Source) but the function there is first written in Java, and one more important thing in that its needs a lot of other functions, also written in Java language.
So my question is: is there a way to use "correctly" this function using Python ?
The following picture shows the differences between the manual and the scripted image treatment.
From the left to the right:
-Fit with splines done manually (edit -> selection -> Fit Splines)
-Fit with splines done automatically (python language)
-One of the script tested to get the Polygon.
 



Thanks by advance,
Damien
Reply | Threaded
Open this post in threaded view
|

Re: Mask smoothing after resizing

André Pereira
Hi All,

I would also be very interested in knowing how to implement in Python the
second option, i.e., reproducing the "Edit>Selection>Fit Spline" from the
GUI into Python code. I can do a "Create Selection", but not the spline
fitting.

Thanks!

My best,
Andre

On 15 July 2015 at 18:05, damien.schnebelen <[hidden email]>
wrote:

> Dear all,
>
> I have another question concerning the smoothing. The method enounced above
> works correctly when I do it by hand, but when I have scripted it in
> Python,
> the results are not the same.
> I've take a look at the java code for the manual function (using Command
> Finders -> Fit Splines -> Source) but the function there is first written
> in
> Java, and one more important thing in that its needs a lot of other
> functions, also written in Java language.
> So my question is: is there a way to use "correctly" this function using
> Python ?
> The following picture shows the differences between the manual and the
> scripted image treatment.
> From the left to the right:
> -Fit with splines done manually (edit -> selection -> Fit Splines)
> -Fit with splines done automatically (python language)
> -One of the script tested to get the Polygon.
>
> <
> http://imagej.1557.x6.nabble.com/file/n5013565/Screen_Shot_2015-07-15_at_6.png
> >
>
>
> Thanks by advance,
> Damien
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Mask-smoothing-after-resizing-tp5013545p5013565.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html