Login  Register

Re: Incorrect density values when quantifying PNG files exported from GIMP

Posted by Robert Baer on Nov 20, 2012; 3:25pm
URL: http://imagej.273.s1.nabble.com/Incorrect-density-values-when-quantifying-PNG-files-exported-from-GIMP-tp5000862p5000898.html

On 11/19/2012 8:17 AM, Garvalov, Boyan wrote:
> Dear Gabriel,
> Thanks a lot for the reply! It is nice to get one from you, I have already read many helpful pieces of advice on ImageJ from you  and have used a number of your plugins for years! Thank you for all that!
> I am aware of the limitations of lossy formats like jpeg and the pitfalls of film scanning and quantification, and I included a couple of comments on that below. But I just wanted to note that the question still remains why in contrast to other programs ImageJ doesn't show and quantify correctly PNG files exported from GIMP. This may be an important question, as millions of people use GIMP and PNG is the default export format in that program. So it may be that there are many people who are quantifying GIMP-generated PNG files with ImageJ and getting substantially incorrect results without realizing it. I myself realized it by accident, after I had already prepared a quantification graph for publication. And the errors, as I mentioned, can be quite substantial, orders of magnitude higher than the differences between a tif scan and a jpg scan.
> Regarding scanning, we do pay careful attention to getting the scanner settings right (which is not the default situation), but the scanner itself is not calibrated. Following your tip I found some instructions on how to do that at http://imagej.nih.gov/ij/docs/examples/calibration/ and will look into the possibility of doing this for our lab scanner.
> Regarding the information loss when saving to jpeg, I have found that it can definitely be an issue e.g. when thresholding and analysing thresholded particles, so there using tif there is better. On the other hand, tests I did with films scanned using our scanner indicate that the differences in density between a tiff scan and a jpeg scan are in the order of 0.01-0.12%. We so far found this to be an acceptable compromise between information preservation and file size.
> Best wishes
> Boyan
Understanding how programs like GIMP interact with ImageJ IS of great
importance so thanks for sharing.  However, I can't quite tell which of
a number of things might be going on.

As I understand it, png supports bit depths of 2, 4,  8  or 16 bits.  Do
you know which bit depth your png files had when you saved them in
GIMP?  When you open your .jpg and .png images in ImageJ and look at
*Image < Type* how is ImageJ interpreting the .png and .jpg images?  Is
it the same in both cases?  If not, is the difference happening at
import or export time.  This is where I would go first with trouble
shooting.

The other minor thing that bothers me is that you talk about rotating
the images.  This could be just "a part of your process" or it could be
critical to the difference in the .png and .jpg export. Is rotation step
critical to the difference in .jpg and .png behavior?

Suppose you bring your original .jpg image into ImageJ and save it as a
.png BEFORE your processing.  Then you open the ImageJ .png in GIMP, do
your thing, and resave as a .png.  Does this produce the same difference
if you compare to .jpg, that is, does it matter where the initial
conversion to .png takes place?

Anyway,  just some troubleshooting ideas!

Rob

>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Dr. Boyan K. Garvalov
> Institut für Neuropathologie
> Justus-Liebig-Universität
> Aulweg 123, 3. OG
> 35392 Giessen
>  
> Tel: (+49-641) 99-41401
> Fax: (+49-641) 99-41689
> E-mail: [hidden email]
> Website: http://www.ukgm.de/ugm_2/deu/ugi_npa/5424.html
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> -----Ursprüngliche Nachricht-----
> Von: ImageJ Interest Group [mailto:[hidden email]] Im Auftrag von Gabriel Landini
> Gesendet: 19 November, 2012 13:40
> An: [hidden email]
> Betreff: Re: Incorrect density values when quantifying PNG files exported from GIMP
>
> On Monday 19 Nov 2012 11:24:04 you wrote:
>> I have been using ImageJ to quantify some images (western blot scans,
>> grayscale). The blots were first scanned in JPG format, then were
>> rotated and cropped using GIMP and finally exported from GIMP either
>> in JPG or PNG format.
> Jpegs (unless the non-lossy version) for imaging are a very bad idea. There are non-lossy formats (like TIFF or PNG) that retain all the scanned information.
> If you load the jpeg to rotate it and save it again in jpeg, you get more lost information. Once saved in jpeg, there is no benefit in converting to PNG, as the loss of information already took place.
>
> It would be better to scan directly to TIFF, then load in IJ and use the
> Image>Transform menu entry to rotate it (no need for the GIMP step).
> It is also necessary to calibrate the scanner too, otherwise the meaning of the darkness in terms of optical density units is unknown.
>
> Regards
>
> Gabriel
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html


--
__________________
Robert W. Baer, Ph.D.
Professor of Physiology
Kirksille College of Osteopathic Medicine
A. T. Still University of Health Sciences
Kirksville, MO 63501 USA


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html