Clean Up errant contour lines

Hi,

I am working on an imaging project with Transmission Electron Microscopy images.

The intent is to understand the texture in the samples and to that end I am using ImageGLCM to classify the textures on a grid of the image.  Using the Haralick parameters calculated from the entire image I can then determine background from foreground which is reflected in the transparent color overlay.  Red is background and blue is foreground/sampleI then take the points that correspond to the sample and I want to understand their distribution and one visualization is to use a contour map.

In the image I have turned show XY markers so you can see the locations of the points I use with appendXYZcontour. Basically it works though I want to clean up the display since some of the contour lines cross the background regions.  Any ideas on how I can clean up those contour lines so they do not extend into the background region (red area).

Andy

contour plot

Is the background region reliably all at a lower topographical level than the sample? If so, you can set manual contour levels that don't include the levels in the background. See ModifyContour manLevels. You may need to turn off the auto levels. Do it the first time with the Modify Contour dialog.

In reply to by johnweeks

Hi John,

Alas no they are not.  Thinking of perhaps a more brute force method and forcing the offending points to NaN, but that would be very computationally expensive. Another idea is to replicate the "background area in a drawing layer.

Andy

Rather than replicating the background to a drawing layer, could you a) duplicate the image, b) set the background region to a solid color value and the foreground region to a transparent color, and c) overlay the duplicate image on top of the image? This makes use of "layering" images, using a foreground image to mask out the background image. This approach would fail if contour lines "bleed through" (ignore) their placement in respect to image layering.

Alternatively, can the contour lines be "embedded" into an image and then eliminated _en masse_ using a 0/1 mask filter image?

(all this is speculation as I have not worked with contours on images)

Hi Andy,

If you don't mind, could you give some details on how you distinguish foreground from background pixels using the Haralick parameters?  I don't see any output from the ImageGLCM function that provides this directly, although I may be missing something.  Is it correct that you down sample the original image to produce the source to ImageGLCM (corresponding to the grid in your example image)?

Also, I see a region in the lower left of the image where background pixels seem to have been misclassified as foreground, however the grid doesn't extend over this region.  

In the interest of providing a solution to a problem that I don't properly understand : ), when the blue/red overlay is created, could you make blue pixels NaN?

Jeff

In reply to by jtigor

Hi Jeff,

 

In ImageGLCM, I use the /HFTP to generate the Haralick parameters.  The image is 4096X4096 pixels and I break it up into 64x64 pixel blocks and calculate the parameters for each block.  There is a post where I get some help to multithread this operation and it still takes ~15 sec.  There are 13 parameters calculated and I use 2 of them to create a filter that corresponds to the background which in these TEMs represent the absence of grid or sample.  I then create an overlay image of size 64,64 and coded 1,0 for background and foreground/sample.  I then set the color with transparency ~0.1 to tint the areas.  I then take a subset of the data that represents foreground for a particular Haralick parameter from a user popup menu and generate a contour map on only those values.  I additionally create a histogram of the parameter. The end user can examine a given parameter to see if they are getting a bimodal/multimodal distribution that would represent different phases in the sample.

The contours are calculated only on xyzzy data from the sample/foreground points but the algorithm can cross the regions that are designated background.

Andy

Andy,

The scatter contour assumes a convex domain.  I do not believe that subdividing your data into smaller domains will help so I am inclined to suggest an approach similar to the one suggested by @jjweimer above.  Once you compute a contour you can access the traces and those can be overlayed with a mask for the forbidden domains.

A.G.

For JJ's idea,  I have the images, which is how I color code the background red and the for ground transparent.

It appears that the drawing order puts traces on top of images and I can change the order within each group, but how would I change such that an image is on top of a trace?

Andy