Author Topic: Image export option for CalcImage  (Read 4806 times)

Julien

  • Professor
  • ****
  • Posts: 84
  • The truth is out there...
    • Geoloweb - J. Allaz personal website
Image export option for CalcImage
« on: December 11, 2017, 01:34:29 PM »
Hi,

We all love CalcImage, and the beautiful maps extracted using the software Surfer from Golden Software is great... However, I found many of my users not having access to Surfer, and either they have to treat their maps using my reprocessing computer, or finding a third party software to do the trick. John suggested that ImageJ should be able to read GRD files, but it would be even better if CalcImage could have an image exportation tool in BMP, or even better in TIF format.

Even more ideally, this little image exportation tool should come with some minimal ability to change the threshold on the intensity of the map (or the weight-% or the atomic proportion...), and to do other basic things, notably choosing the gradient color and doing some minimal math on the maps (what can already be done in CalcImage, but what will generate another DAT or GRD file, and not an actual image if I am correct...).

I envision the following:

  • Have some kind of routine that allows the user to constrain the minimum & maximum intensity (Z) value. The value will be either an intensity or a weight-% value, so this parameter will have to be a float number.
  • There could be additional options, like the color scale (grayscale, rainbow… you already have these options in the software)… Maybe there are packages similar to the graph options in PfE that could be integrated into CalcImage?
  • Once the user has set these values, the Z-value is scaled back from 0 to 255, 0 being the minimum intensity the user entered and 255 being the maximum. You could even think about have a toggle box for the log scale output (for when you are mapping an element present as minor in one phase and major in the other...).
  • Export these values in a TIF or BMP file.

Of course, there should also be a batch option to allow for the treatment of all element maps at once. Maybe the threshold value could be saved in a little text file, and be recalled when the batch process is activated?

BTW, it would be good one day to move away from that decaying Bitmap format. Way to heavy. TIF is the best way to go, you can even use lossless compression and end with files 4-5x lighter than BMP. Something for Probe for EPMA version 20 - The Golden Xtreme Plus Edition :D ?

I honestly have no idea how you generate images through a script in VB or so, so maybe what I personally think is simple in my mind might be a hassle to code…

Cheers,

Julien

glennpoirier

  • Professor
  • ****
  • Posts: 54
Re: Image export option for CalcImage
« Reply #1 on: December 12, 2017, 05:50:24 AM »
Hi Julien,
What I've been doing is converting the *.GRD files to  16 bit TIFFS and working with them in imagej. This works well because the pixel values of the 16 bit images are the real data (i.e. oxide wt%, detetction limit etc). Once I've got the data in imagej I can do all the manipulation and whatever else I want to do. My favourite is to throw all the quant maps into a stack and use a quick macro to calculate average compositions for a selected area. I've been using imagej since it first became available and I'm much happier using  it

The conversion is done using an R script I've cobbled together from some code initially posted to the forum by Ben Buse, I can send it to you if you like.


Cheers

Glenn

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Re: Image export option for CalcImage
« Reply #2 on: December 12, 2017, 08:09:06 AM »
Hi Julien,
What I've been doing is converting the *.GRD files to  16 bit TIFFS and working with them in imagej. This works well because the pixel values of the 16 bit images are the real data (i.e. oxide wt%, detetction limit etc). Once I've got the data in imagej I can do all the manipulation and whatever else I want to do. My favourite is to throw all the quant maps into a stack and use a quick macro to calculate average compositions for a selected area. I've been using imagej since it first became available and I'm much happier using  it

The conversion is done using an R script I've cobbled together from some code initially posted to the forum by Ben Buse, I can send it to you if you like.

Hi Glenn,
Your R script converts the GRD files to 16 bit TIFF?   Does it convert by file or by folder?

Can you post it here?
john
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

glennpoirier

  • Professor
  • ****
  • Posts: 54
Re: Image export option for CalcImage
« Reply #3 on: December 12, 2017, 09:12:28 AM »
Hi John,
It converts by folder and produces 32 bit tiffs (not 16 like I said earlier) as well as PNGs with a colour scale. It does what I need and nothing else so please don't laugh at my code ;)

The script is meant to run in RStudio, you could probably run it in the R command line but I haven't tried. You'll need to install the sp, raster and rasterVis packages.

Set the working directory in RStudio to the directory containing the folders you want to convert  and run the code. If it doesn't work the first time try again, the first run occasionally doesn't work (library issues?). I haven't lost any data but you should be careful.

Obviously this is an absolute minimal piece of code, if anyone makes improvements please post them! I'd especially like to know why the levelplot function doesn't work.

Cheers

Glenn

PS: If anyone has succeded in opening GRD file in ImageJ I'd love to know how.
« Last Edit: December 12, 2017, 09:44:30 AM by John Donovan »

Philipp Poeml

  • Professor
  • ****
  • Posts: 222
Re: Image export option for CalcImage
« Reply #4 on: January 12, 2018, 08:18:04 AM »
There are also scripts for surfer's scripter floating around in the forum that convert whole directories of grd files to imageJ readable formats with real data (counts) in them. Easy to convert and then everything can be done in imageJ.

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Re: Image export option for CalcImage
« Reply #5 on: January 12, 2018, 04:03:48 PM »
I don't know if this is any help, but attached below is the VB code I use to read and write Surfer GRD files.

Note that it supports both the older (up to Surfer 6) format and the newer (Surfer 7 and higher) GRD formats.  We can all probably ignore the older format as I doubt that anyone is still running Surfer 6 or older...
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"