# MorphologicalPerimeter[] unstable behaviour with increasing threshold values

I have a PET image represented as a list of lists of grey value intensities. Here you can find the file in a "MAT" format (you can import it like: filteredData = Flatten[#,1]&@Import["filteredData.mat", "MAT"];).

I am using MorphologicalPerimeter[] to implement a threshold based simple image segmentation. My code looks like this:

Manipulate[
ImageCompose[
ArrayPlot@filteredData, {
MorphologicalPerimeter[ArrayPlot@filteredData,
actThreshPercent*Max@filteredData/100],
0.2
}
],
{actThreshPercent, 1, 100, 1}
]


For threshold = 40:

If I increase the threshold, the perimeter of the curve that is returned by MorphologicalPerimeter[] becomes smaller then larger and so on. Shouldn't it be steadily smaller as the threshold increases ?

For threshold = 55:

Specs: Mathematica 11, Mac OSX.

The problem is that you are applying MorphologicalPerimeter to the ArrayPlot (and not just the data within the plot). Use Image instead:

Manipulate[MorphologicalPerimeter[Image[filteredData, ImageSize -> 500],
tau*Max@filteredData/100.], {tau, 1, 100}]


and you will see the perimeter shrinks monotonically as you increase the threshold parameter.

There are lots of ways to superimpose images. First, turn the data into an image

img = ColorNegate[Image[filteredData, ImageSize -> 500] // ImageAdjust]


then use ImageMultiply

Manipulate[ImageMultiply[img, ColorNegate@
MorphologicalPerimeter[Image[filteredData, ImageSize -> 500],
tau*Max@filteredData/100.]], {tau, 1, 100}]

• Thanks bill. How could I superimpose the resultant image to my original one? – stathisk Aug 27 '16 at 21:01