Thanks for the reply.

As it turns out, the problem was more complicated. It seems that the ~200 
images were NOT all saved at the same scale.  Some were pretty close, but 
others were way off.

The good news is that each image had an easily recognizable scale bar.  The bad 
news is that most of the scale bars were 1mm in length (in real world 
coordinates) and some were 500 micrometers (0.5mm).

So...after writing one plugin to apply a single "pixelHeight/Width" to all the 
images, I ended up writing a plugin to automatically find and measure the scale 
bar, GUESS whether it was 1mm or 0.5mm, and then attach a Calibration to the 
image.

Works like a charm, but only useful for one 200-image project.  I suppose it 
might be useful for other images captured with the same camera.

We will now have a conversation with the lab tech who scaled and cropped the 
images "by eye" to make them all pleasing to look at (and controlled the 
original imaging so that the camera added different size scale bars to the 
images).

--
Kenneth Sloan
[email protected]
Vision is the art of seeing what is invisible to others.





> On Jun 21, 2024, at 19:08, Fred Damen <[email protected]> wrote:
> 
> Greetings Kenneth,
> 
> The TIFF file format can save more than just the pixel data. The pasted
> code below is what I stole from ImageJ code that saves TIFF files, so it
> should be the same as stock.  The two points of interest for you is
> FileInfo and properties. FileInfo I believe contains the calibration that
> you are interested in. If not, the properties, see
> ImagePlus.setProperties, can be used to store the information that you can
> use to reconfig the imported TIFF files to your liking.
> 
> For the calibration info separate from the TIFF files, google 'java
> properties saving to file'.
> 
> Enjoy,
> 
> Fred
> 
> 
>   public static boolean saveTiff(OutputStream os, ImagePlus imp) throws
> IOException {
>      FileInfo fi = imp.getFileInfo();
>      fi.description = (new FileSaver(imp)).getDescriptionString();
>      fi.info <http://fi.info/> = imp.getInfoProperty();
>      fi.properties = imp.getPropertiesAsArray();
>      if (imp.getProperty(Plot.PROPERTY_KEY) != null) {
>         Plot plot = (Plot)(imp.getProperty(Plot.PROPERTY_KEY));
>         fi.plot = plot.toByteArray();
>         }
>      fi.roi = RoiEncoder.saveAsByteArray(imp.getRoi());
>      fi.overlay = FileSaver.getOverlay(imp);
>      fi.sliceLabels = imp.getStack().getSliceLabels();
>      if (imp.isComposite()) (new
> FileSaver(imp)).saveDisplayRangesAndLuts(imp, fi);
>      if (fi.nImages>1 && imp.getStack().isVirtual())
>         fi.virtualStack = (VirtualStack)imp.getStack();
> 
>      TiffEncoder te = new TiffEncoder(fi);
>      te.write(os);
>      return true;
>      }
> 
> 
> On Fri, June 21, 2024 6:37 am, Kenneth R Sloan wrote:
>> I have about 200 .tif images in about 5 directories. They are identical in
>> scale, and all contain a scale bar in a fixed position and known length.
>> 
>> I would like to attach a Calibration to every image, based on a user
>> selecting the two ends of the scale bar in one image, and then propagating
>> that Calibration to the same ther images.
>> 
>> My plan is one Java plugin (I’m most comfortable with these) to
>> establish
>> the Calibration and save it (how?  What format?) and then another to allow
>> the user to specify the saved scale information and a directory contained
>> Ning many images.  This second plugin would simply attach the Calibration
>> to every image in the directory and overwrite the images.
>> 
>> Any hints?
>> 
>> For now I think I just want mm/pixel, but it might be nice to generalize
>> to
>> all parameters of a Calubration.
>> 
>> -Kenneth Sloan
>> 
>> 
>> On Fri, Jun 21, 2024 at 05:27 CARL Philippe (LBP)
>> <[email protected] <mailto:[email protected]>>
>> wrote:
>> 
>>> Dear all,
>>> With the macro instruction RoiManager.selectGroup(group) I can select a
>>> bunch of ROIs which have previously be set as being part of a given
>>> group.
>>> How can I then get the indexes of the selected ROIs ?
>>> RoiManager.selected gives me only the number of selected ROIs.
>>> As roiManager("index") gives me only "the index of the first selected
>>> ROI
>>> if more than one is selected".
>>> Thus it seems that a macro instruction like roiManager("indexes") is
>>> missing.
>>> Or is there an alternative method that I may be missing ?
>>> Thanks a lot in advance for your help.
>>> My best regards,
>>> Philippe
>>> 
>>> Philippe CARL
>>> Laboratoire de Bioimagerie et Pathologies
>>> UMR 7021 CNRS - Université de Strasbourg
>>> Faculté de Pharmacie
>>> 74 route du Rhin
>>> <https://www.google.com/maps/search/74+route+du+Rhin?entry=gmail&source=g>
>>> 67401 ILLKIRCH
>>> Tel : +33(0)3 68 85 41 41
>>> 
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>> 
>> 
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>> 
> 
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html


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

Reply via email to