Author Topic: CalcImage RGB Overlays?  (Read 6544 times)

Dan R

  • Professor
  • ****
  • Posts: 82
    • GE Research Materials Characterization
CalcImage RGB Overlays?
« on: January 10, 2014, 05:21:59 AM »
Hi all-
I was looking around in CalcImage after making some Quant maps (which are awesome by the way!) and I didn't see any option to combine 3 elemental maps into a single RGB image (e.g., R: Fe Ka, G: S Ka, B: Cu Ka). I didn't see anything about this in the help files or on the forum, is this feature not available with CalcImage? I ended up using ImageJ...
Thanks for any info!
-Dan

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Re: CalcImage RGB Overlays?
« Reply #1 on: January 10, 2014, 09:51:29 AM »
Hi Dan,
I was wondering when someone would ask about this...  :)

I am working on a totally new idea for manually and automatically rotating through the elements and colors to find interesting phase relationships quickly but it's not quite ready for production yet.

I'll post it in the CalcImage New Features topic when it's ready!
john
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Ben Buse

  • Professor
  • ****
  • Posts: 499
Re: CalcImage RGB Overlays?
« Reply #2 on: March 05, 2015, 08:57:03 AM »
Hi Dan,

You can make nice rgb images in surfer.

Steps
1. open surfer
2. Map - New - Image Map (select grid file for 1st element)
3. Select image
4. Map - Add - Image Layer (load grid file for 2nd element; repeat for 3rd element)
5. For each image layer: [steps 1-6 on image]
Change color scale so that it goes from transparent to solid red for 1st element - you need to uncheck
"apply opacity to ALL nodes"
Then change other image layers to transparent to solid green/blue
See image


John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Re: CalcImage RGB Overlays?
« Reply #3 on: March 09, 2015, 07:03:21 PM »
I've just uploaded a first cut of the new RGB processing window in CalcImage. Calculations can be performed on any of the output data types (elemental quant, atomic, oxide, etc etc.).

One can rotate through the elements or rotate the RGB colors for the selected elements as seen here:

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

"Not Absolutely Certain, Yet Reliable"

Gareth D Hatton

  • Professor
  • ****
  • Posts: 51
Re: CalcImage RGB Overlays?
« Reply #4 on: March 12, 2015, 03:20:38 AM »
RGB overlays are a tricky subject if you look at the literature on co-localisation.

There are two approaches, the one that Ben has shown and is the implementation which has been chosen by John.  This is merely plotting the pixels from more than one map onto the same space (forgive me if it is not that simple John), if they coincide then you may get some colour change but it is not consistent, it depends heavily on the concentrations of the components.  If one has a higher concentration it is likely to swamp the others.  If they are co-localised we need clear colour change with a range reflecting the intensity differences.  This is a common problem which has been discussed in the literature.  It is high dependent upon relative intensities (see http://medicine.emory.edu/documents/mimcore/bolte-guided-tour-coloc-jmrosc2006.pdf). 

Merge images are being moved away from in the field of biology and various coefficients are taking their place as well as scatter plots. A lot seem to use Pearson’s image correlation coefficient.  This only compares two images as far as I can tell.  There is a great intro to this here: http://www.pasteur.gr/wp-content/uploads/Quantitative-Imaging-for-Colocalization-Analysis.pdf

As Dan Ruscitto pointed out he used ImageJ for this.  From my previous perusing of this area it could be the best place to go.  My thoughts now wander to a more philosophical discussion on what we as a community want or need.  Do we want an all in one solution from John where he works on re-inventing the wheel or do we want him to work on improving our ability to collect good quality data easily and consistently which he is very good at?  To my mind it may be better to request an easy output to individual quantified tiff files with headers for further processing in a programme such as ImageJ with some discussion on the forum about how we use these tools (a new section in the forum?).

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Re: CalcImage RGB Overlays?
« Reply #5 on: March 13, 2015, 09:02:44 AM »
RGB overlays are a tricky subject if you look at the literature on co-localisation.

There are two approaches, the one that Ben has shown and is the implementation which has been chosen by John.  This is merely plotting the pixels from more than one map onto the same space (forgive me if it is not that simple John), if they coincide then you may get some colour change but it is not consistent, it depends heavily on the concentrations of the components.  If one has a higher concentration it is likely to swamp the others.  If they are co-localised we need clear colour change with a range reflecting the intensity differences.  This is a common problem which has been discussed in the literature.  It is high dependent upon relative intensities (see http://medicine.emory.edu/documents/mimcore/bolte-guided-tour-coloc-jmrosc2006.pdf). 

Merge images are being moved away from in the field of biology and various coefficients are taking their place as well as scatter plots. A lot seem to use Pearson’s image correlation coefficient.  This only compares two images as far as I can tell.  There is a great intro to this here: http://www.pasteur.gr/wp-content/uploads/Quantitative-Imaging-for-Colocalization-Analysis.pdf

As Dan Ruscitto pointed out he used ImageJ for this.  From my previous perusing of this area it could be the best place to go.  My thoughts now wander to a more philosophical discussion on what we as a community want or need.  Do we want an all in one solution from John where he works on re-inventing the wheel or do we want him to work on improving our ability to collect good quality data easily and consistently which he is very good at?  To my mind it may be better to request an easy output to individual quantified tiff files with headers for further processing in a programme such as ImageJ with some discussion on the forum about how we use these tools (a new section in the forum?).

Hi Gareth,
Very interesting.   I did not know of this literature, but I'm not surprised of course.   

And I agree, that the RGB methods that Ben and I are using are related but different.  This is because the Surfer method that Ben showed is based on the transparency component, while the method I am using is, as you said, based on the more classical method of calculating the fractional components for the RGB values in the 24 bit color value.  Here is the code I am using:

' Loop through all pixels in RGB channels
For ipixely& = 1 To iy&
For ipixelx& = 1 To ix&
ipixels& = ipixels& + 1

' Check for blanking value (only on first image)
If InputArray!(ipixelx&, ipixely&, 6) <> BLANKINGVALUE! Then
RGB_WtPercents!(1) = InputArray!(ipixelx&, ipixely&, R_Column%)
RGB_WtPercents!(2) = InputArray!(ipixelx&, ipixely&, G_Column%)
RGB_WtPercents!(3) = InputArray!(ipixelx&, ipixely&, B_Column%)

' Calculate composite color
If RGB_WtPercents!(1) + RGB_WtPercents!(2) + RGB_WtPercents!(3) <> 0# Then
RGB_Fractions!(1) = RGB_WtPercents!(1) / (RGB_WtPercents!(1) + RGB_WtPercents!(2) + RGB_WtPercents!(3))
RGB_Fractions!(2) = RGB_WtPercents!(2) / (RGB_WtPercents!(1) + RGB_WtPercents!(2) + RGB_WtPercents!(3))
RGB_Fractions!(3) = RGB_WtPercents!(3) / (RGB_WtPercents!(1) + RGB_WtPercents!(2) + RGB_WtPercents!(3))

' Check for range
If RGB_Fractions!(1) < 0# Then RGB_Fractions!(1) = 0#
If RGB_Fractions!(2) < 0# Then RGB_Fractions!(2) = 0#
If RGB_Fractions!(3) < 0# Then RGB_Fractions!(3) = 0#

If RGB_Fractions!(1) > 1# Then RGB_Fractions!(1) = 1#
If RGB_Fractions!(2) > 1# Then RGB_Fractions!(2) = 1#
If RGB_Fractions!(3) > 1# Then RGB_Fractions!(3) = 1#

' Save to BMP array
RGB_Color_Array&(ipixelx&, ipixely&) = RGB(CByte(RGB_Fractions!(1) * 255), CByte(RGB_Fractions!(2) * 255), CByte(RGB_Fractions!(3) * 255))
End If      ' zero sum check
End If      ' blanking value check

Next ipixelx&
Next ipixely&


Nothing surprising there...

And you are also correct that the highest intensity or concentration tends to dominate the RGB color.  But that got me thinking about this post here:

http://probesoftware.com/smf/index.php?topic=427.msg2373#msg2373

where I pointed out to Ben Buse about using the "log weight percents" to see subtle variations when you have a range of variation on different scales. 

So I checked and found that although I am calculating the log wt% GRD files for display in CalcImage, I wasn't outputting the log wt% classify output .DAT file that is used for post processing. That is remedied in the latest PFE update.

So, what does that do in RGB space...?  Well here's normal elemental quant wt% for an amphibole bearing basalt:



We can see that because Si is a high concentration in many pixels, and because it is assigned green in RGB space, most of the image shows as green without a lot of differentiation. Now, here is the *same* data but expressed as Log wt%:



Now, let's admit it.  That is a striking improvement.

I don't know if anyone else has utilized this "RGB log weight percent" technique previously, but if it hasn't been published I would be happy to work with someone to willing to write up an short abstract or poster.  And I would be pleased to assist as last author if that would be helpful...
« Last Edit: March 13, 2015, 09:05:50 AM by John Donovan »
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Ben Buse

  • Professor
  • ****
  • Posts: 499
Re: CalcImage RGB Overlays?
« Reply #6 on: March 16, 2015, 03:11:06 AM »
Gareth, that's very interesting.

RGB can be very useful to quickly visualize distribution of phases - especially in simple system - as in experiments where the number of components is limited e.g. MASH - Mg, Al, Si, H2O. But by its nature it is limited it poorly displays the complexicties of a multi elment system for which the already implemented cluster phase analysis is much better. As I understand RGB the key thing is to have it based on weight % or atomic % as John has done so that it reflects changes in proportions and not raw counts .

Looking to the future - scatter plot analysis of x-ray maps is very interesting. Quant x-ray maps are very powerful there's a lot of data in there and its how to use it best. I have previously used scatter plot correlation maps in imagej using a plugin (https://sils.fnwi.uva.nl/bcb/imagej/correlate-with-mask/Correlate-8.pdf) but this was limited to x-y plots -its big advantage is being able to remove or exclude mixed data from the boundaries of phases. I think the key thing with quant x-ray maps is that they have two uses (1) identify phases and there proportions and (2) extract good quantitative data - where not possible in conventional analysis. In the latter case examples include microlites in a glass at the limit of analytical resolution - where only the centre of the microlite gives good data. Particular where the microlites are unstable (requiring maps at low beam current/short dwell time) being able to extract the data from the core of say all plagioclase microlites within an image would be very powerful. On scatter plots you can for example select the centre of a cluster and ignore the edges of the cluster which reflect mixed analysis. Another example is in vesicular glass or coraline algae (where your analysing the cell wall which is very vesicular) - in these cases you want to be able to extract the composition from the material between the holes - & due to the ubituqeuous of the holes it becomes difficult to select points. In both glass and carbonate it is unstable so being able to average noisy data (excluding holes) has a huge advantage. I've tried this using matlab (exporting quant grid maps as xyz.dat) but its difficult to make scripts user friendly so that other labs users can use them.

I just thought in the case of holes within a map - these can already be excluded using CalcImage - Classify Points (Min-Max)  - I will have to give this a go
« Last Edit: March 16, 2015, 04:01:51 AM by Ben Buse »

Ben Buse

  • Professor
  • ****
  • Posts: 499
Re: CalcImage RGB Overlays?
« Reply #7 on: March 23, 2015, 03:28:09 AM »
Further thoughts regarding RGB.

I'd suggest RGB provide a useful tool to visualizing the distribution of 3 components. Their simplicity is whats great its easy to relate what you see to the raw data.

With RGB you don't have to worry about how the mineral phase algothrim deals with zoning within crystals or mixed anlysis boundary phases your brain intrepretes the picture.

I like the way John has implemented it so that the RGB is correct i.e. proportion of elment fraction expressed in weight percent. I should mention the example I showed in surfer was skewed as I had not changed the color scale for each elment to 0 to 100% first, rather it was set to min and max for each elment which over emphases the minor components - although this may be useful. The idea of log RGB sounds interesting and may be useful to see disbution of trace and major elments but is not as intuitive as pure RGB.