Author Topic: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples  (Read 1677 times)

Gseward

  • Global Moderator
  • Professor
  • *****
  • Posts: 130
Q: What is Extract Polygon Areas and/or Perform Pixel Filtering, anyway?

A: Extract Polygon Areas and/or Perform Pixel Filtering is a tool in the CalcImage ‘Image Processing’ menu to enable the extraction/filtering of a subset of data from an EPMA X-ray-map dataset. The tool utilizes a CalcImage-derived _Classify .DAT file as input (element wt%, oxide wt%, atomic%, net intensity etc.). 

Gseward

  • Global Moderator
  • Professor
  • *****
  • Posts: 130
Re: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples
« Reply #1 on: November 28, 2018, 12:43:18 pm »
Here is how Filtering works:

The ‘Pixel Filtering’ method is used to create a subset of data based on a user-defined range of values for a given channel(s) in the _Classify.DAT input file. The result of the filtering operation can be displayed as a list of compositions for all the filtered pixels and/or an average composition. Filtered values can then be written to a Tab Delimited File or used to create a Surfer .GRD file (for each channel) to be displayed in the main CalcImage window.

Here is an example where Pixel Filtering is used to remove pixels with analysis totals >95% and <102%:



Open a Quant_Image_Classify.DAT file (1)
Select the input data channel to be displayed (2) (in this case either an element wt%, Calc O or Total).
Select the checkbox for the Filtering Component(s) of interest and set the required range (3), in this case a Total >95 and <102. Note that the Min/Max value for each component is displayed, as is the value for the current cursor position.
Click the ‘Perform Extraction/Filtering’ button (4). The result of the Filtering is displayed in the center pane (5). By default, the ‘Calculate Polygon Averages Only’ box is checked (6) and only a single composition is returned. Uncheck the ‘Calculate Polygon Averages Only’ to output a composition for each individual pixel (12) (this may take some time!). The output text can be copied to the clipboard (7).

For more complete documentation or more complex operations, the output can be written directly to file (#8) or as a Surfer .GRD file (9) to be displayed in the main CalcImage display window. When writing to file it may be useful to append multiple filtering operations to the same file (10). In this case it may also be useful to associate a unique index with each operation using the Enumerate checkbox (11).



Example .GRD output (Main CalcImage window) pixels with Na wt% >7<11.4 AND Total >95<102. All other pixels are ‘blanked’ (13).





Gseward

  • Global Moderator
  • Professor
  • *****
  • Posts: 130
Re: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples
« Reply #2 on: November 28, 2018, 12:51:31 pm »
Here is how Extract Polygon works:

The ‘Extract Polygon Area’ method is used to create a subset of data based on a user-defined area of interest. The result of the extraction operation can be displayed as a list of compositions for all the extracted pixels and/or an average composition. Extracted values can then be written to a Tab Delimited File or used to create a Surfer .GRD file (for each channel) to be displayed in the main CalcImage window. The ‘Extract Polygon Area’ method can be used concomitantly with the ‘Pixel Filtering Method’ operations described above.

Here is an example where Polygon Extraction is used to sample the average composition of subdomains of an X-ray map dataset:



Open a Quant_Image_Classify.DAT file (1) and select the input data channel to be displayed (2) (in this case either an element wt%, Calc O or element by difference).
Select ‘Digitize Polygon’ (3) and then click on the image to digitize the outline of the desired polygon. Once digitization is complete click ‘Close Polygon’ (3).
Select the text output options required (4). In this case the intention is to draw multiple polygons and extract an average composition (i) to a file (ii) containing data for multiple polygon extractions (iii) where each extraction is indexed with a unique number (iv).
Click the ‘Perform Extraction/Filtering’ button (5). The output for the most recent polygon extraction is displayed in the center pane (6). The polygon index in the text-output matches the index in the associated image.
For documentation and reference purposes it is useful to save an image of the digitized polygon areas (7a-b). If necessary, the overlay graphics can be removed (#8).

Gseward

  • Global Moderator
  • Professor
  • *****
  • Posts: 130
Re: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples
« Reply #3 on: November 28, 2018, 01:00:26 pm »
Here is an example of combining both Pixel Filtering and Polygon Extract into a single operation:

It is also possible to combine the Polygon and Filtering methods to build greater complexity into the extraction process. Here is an example where Polygon Extraction and Filtering are used in combination to extract the composition for a specific zone within a mineral whilst avoiding extracting inclusions:



Using the method previously described for Polygon Extraction, one can easily digitize a convoluted polygon (1) and extract the data. The average composition for Polygon Extraction #13 is displayed in the center pane (2). However, the digitized area contains pixels from many small inclusions that could have an undesirable effect on the calculated average composition. To assess potential problems, it is helpful to be able to simultaneously visualize the extracted data for all elements. This is achieved by checking ‘Create Surfer .GRD File for each Element’ (3), and viewing the output in the main CalcImage display window.  Note that pixels that were not in the extracted area have been ‘blanked’ (A) in the output images (Purple in this case). Inclusions (B).



Once the composition of undesirable pixels is known, Pixel Filtering can potentially be used to exclude the pixels. Composition of problematic inclusions can be assessed using either the Cursor composition column in the ‘Extract Polygon Areas’ window (4) or the Hyper Cursor option (Windows | Use Hyper Cursor) in the main ‘CalcImage’ window.

A combination of Polygon Extraction (1) and Pixel Filtering based on Fe, Al (2) are now used to extract an inclusion-free (A) average composition for the zone of interest. Adding filtering based on Mn also facilitates using a less convoluted polygon.






Gseward

  • Global Moderator
  • Professor
  • *****
  • Posts: 130
Re: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples
« Reply #4 on: November 28, 2018, 02:12:47 pm »
But what about the 'Shape Extraction option???

The ‘Shape Extraction’ method is a modification of the ‘Extract Polygon Area’ method. The extracted area is a predefined shape with specific dimension. This method is useful for extracting ‘spot’ measurements of composition across a quantified X-ray-map dataset. The ‘Shape Extraction’ method can be used concomitantly with the ‘Pixel Filtering Method’ operations described above.



Open a Quant_Image_Classify.DAT file (1) and select the input data channel to be displayed (2) (in this case either an element wt%, Calc O or Total).
In the Shape Extraction pane (3) define the dimensions of the shape and select the text output options required. In this case the intention is to select and extract the average composition and the composition of all pixels (i), export the output to file (ii) and append multiple extractions to the same file (iii), indexed with a unique number (iv).
Select ‘Shape Extraction On’ (v) and then click on the image to select an area. The output for the most recent Shape Extraction is displayed in the center pane (4).The average composition and the composition for all pixel is displayed. The Shape Extraction index in the text-output matches the index in the associated image.
For documentation and reference purposes it is useful to save an image of the digitized Shape Extraction areas (5a-b). If necessary, the overlay graphics can be removed (6).

In this example the X-ray-map dataset was collected prior to data collection using ion-beam and Laser Ablation techniques. After the fact, the Shape Extraction tool can be used to extract an elemental composition for the areas that correspond to measurements acquired with the other techniques (Surfer was used in this case, but the principle is the same). The use of PictureSnapApp, as a navigation tool across all the different instrument, simplifies the process of locating and relocating areas of interest.








Ben Buse

  • Professor
  • ****
  • Posts: 414
Re: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples
« Reply #5 on: November 29, 2018, 02:26:21 am »
Hi Gareth,

This looks really good, what be nice to try is with something like a plagioclase with sharp zones can you extract the average composition of each zone using the polygon and filtering method

Ben

Ben Buse

  • Professor
  • ****
  • Posts: 414
Re: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples
« Reply #6 on: November 29, 2018, 03:48:57 am »
I've just tried it and it seems to work well - and its easy to use, a great feature Gareth and John- here's the polygon extract and filter image. There is a small problem however, with calcimage cropping the workable image - see below. Also a small question for the average do you use the mean or median?

grid surfer image showing pixels selected


GUI of calcimage, with results and polygon shown


The image shown in calcimage is only part of the image - the full image is shown below

« Last Edit: November 29, 2018, 03:59:29 am by Ben Buse »

Gseward

  • Global Moderator
  • Professor
  • *****
  • Posts: 130
Re: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples
« Reply #7 on: November 29, 2018, 09:49:54 am »
Thanks for trying it out Ben! More features to come, soon!

Quote
The image shown in calcimage is only part of the image - the full image is shown below

John is aware of this issue already. You can see the same issue in the images relating to Shape Extraction.

https://probesoftware.com/smf/index.php?topic=1151.msg7859#msg7859

Gseward

  • Global Moderator
  • Professor
  • *****
  • Posts: 130
Re: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples
« Reply #8 on: November 29, 2018, 10:44:01 am »
Hi Gareth,

This looks really good, what be nice to try is with something like a plagioclase with sharp zones can you extract the average composition of each zone using the polygon and filtering method

Ben

Ben,

I'm guessing the effectiveness of the Filtering will partly be related to the precision in the original map. But here is a first pass based on the Plag in the previous posts:



I filtered (1) based on Mg and K (to remove inclusions) and a narrow Na concentration window to filter the zoning (combinations of Na/Ca/Si/Al might be good also).
Digitized a polygon around the grain of interest (2)
Selected output to .grd (3) and then extracted the pixels (4).

I did three separate extractions with Na<2.9>3.1, Na<3.1>3.3, Na<3.3>3.5. To make an easy-to-see visual of each extraction, I Saved each Na .grd as a .bmp in  the main CalcImage window and then processed the 3 images in imageJ





« Last Edit: November 29, 2018, 10:45:42 am by Gseward »

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 2487
  • Other duties as assigned...
    • Probe Software
Re: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples
« Reply #9 on: December 01, 2018, 09:02:26 am »
Thanks for trying it out Ben! More features to come, soon!

Quote
The image shown in calcimage is only part of the image - the full image is shown below

John is aware of this issue already. You can see the same issue in the images relating to Shape Extraction.

https://probesoftware.com/smf/index.php?topic=1151.msg7859#msg7859

Hi Ben and Gareth,
This image display issue should be fixed now in v. 12.5.3.
john
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Gseward

  • Global Moderator
  • Professor
  • *****
  • Posts: 130
Re: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples
« Reply #10 on: December 03, 2018, 02:11:48 pm »



Hi Ben and Gareth,
This image display issue should be fixed now in v. 12.5.3.
john

John,

Not sure it is fixed!



The Image is 'all there' because if I copy and paste it to clipboard I can see the uncropped version. It seems like it is cropped by the window sizing.

Gareth

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 2487
  • Other duties as assigned...
    • Probe Software
Re: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples
« Reply #11 on: December 03, 2018, 08:32:40 pm »
Ok, as requested by Gareth Seward I added a "save all images to bmp files" menu in CalcImage.  These images are saved with the stage coordinate ACQ calibration files so they can be subsequently loaded into PictureSnap or PictureSnapApp and used to navigate to:


John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 2487
  • Other duties as assigned...
    • Probe Software
Re: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples
« Reply #12 on: December 03, 2018, 08:51:14 pm »
John,

Not sure it is fixed!

The Image is 'all there' because if I copy and paste it to clipboard I can see the uncropped version. It seems like it is cropped by the window sizing.

Gareth

Hi Gareth,
OK, I think it is finally fixed now:



Sorry about that!   You can download now using the Help menu in PFE.
john
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Gseward

  • Global Moderator
  • Professor
  • *****
  • Posts: 130
Re: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples
« Reply #13 on: December 04, 2018, 09:11:22 am »

Hi Gareth,
OK, I think it is finally fixed now:



Sorry about that!   You can download now using the Help menu in PFE.
john

Thanks a lot John.
BTW I also like the options in the Convert menu.
Gareth
« Last Edit: December 04, 2018, 09:46:15 am by John Donovan »

Probeman

  • Emeritus
  • *****
  • Posts: 1955
  • Never sleeps...
    • John Donovan
Re: CalcImage Extract Polygon and Filtering Methods Tutorial/Examples
« Reply #14 on: December 04, 2018, 11:49:16 am »
The following post only applies to Cameca EPMA instrument users.

When I first notified Gareth that the polygon/shape pixel extraction window should now be properly showing the full image extents, he pointed out that the image I sent him appears to have been "flipped" with respect to how it appears on his computer.  This is related to the fact that he is running a Cameca SX100 with a cartesian stage, as opposed to the JEOL EPMA instrument's anti-cartesian stage, and I was loading his classify .DAT file in JEOL mode on my off-line computer.

The reason for this is that Probe for EPMA installs by default in JEOL mode (I'm guessing, but probably around 80-90% of EPMA instruments in the world are JEOL). So if you install Probe for EPMA on a computer, the first time you run it, it starts in JEOL mode.

Because the software installs by default in JEOL mode there is no issue for off-line processing for JEOL users, but Cameca instrument users may experience a little confusion when installing Probe for EPMA on a *new* off-line computer.

However, for every situation that I can think of in Probe for EPMA and CalcImage, except when loading a classify .DAT file, one will not notice a difference in the image orientations. The software will handle the image orientations transparently and only the stage coordinates are properly inverted as they should be.

But in the case of loading the classify .DAT files in CalcImage for pixel extraction, when the acquired image instrument configuration does not match the off-line software configuration (JEOL vs. Cameca), the Probe for EPMA currently loads the image to match the current stage coordinate system, which caused the image "flip" that Gareth observed.  Again, this will only occur on off-line computers when processing data from Cameca instruments, and the off-line computer configuration is specified as JEOL.

It would have been too easy if both JEOL and Cameca instrument stages utilized the same orientation!!!!

This image "flipping" when loading a Cameca classify .DAT file on a JEOL configured off-line computer, will be fixed soon, but in the meantime there is a simple solution: simply start Probe for EPMA on your off-line computer and answer "Yes" to the first question when it asks whether to connect to the instrument (it will connect in simulation mode of course since it is an off-line computer).

Then click the File menu and select the menu Use Cameca Simulation Mode as seen here:

https://probesoftware.com/smf/index.php?topic=837.msg5978#msg5978

Your off-line computer will now be in Cameca configuration mode and everything will be fine from now on. Again, JEOL instrument users can ignore this entire post.
The only stupid question is the one not asked!