Login  Register

Re: Scale bar macro problems

Posted by Nick Holway on Sep 04, 2008; 3:01pm
URL: http://imagej.273.s1.nabble.com/Scale-bar-macro-problems-tp3695175p3695177.html

Hi,

Thanks for the response.I followed your suggestion and it worked to solve
the image bar width problem. I didn't realise that it was called for each
image and had kept outside of the loop to try and make the script more
efficient.

I noticed when running the script that the "no images open" message actually
occured when it tried to process the thumbs.db file. The fact I had no
images open was a red herring. I'll alter my script so it'll only open
images.

Nick

2008/9/4 Michael Schmid <[hidden email]>

> Hi Nick,
>
> in your macro, the "Set Scale..." command is called before
> opening the image, so it will create an error if there is no
> open image at that time.
> You should call it each time after you open an image.
>
> Tiff images have the image scale stored as tags with the image,
> which might cause a scale different from that of the jpegs.
> Again, this problem should be none if you call "Set Scale..."
> after "open".
>
> Michael
> ________________________________________________________________
> Michael Schmid                    email: [hidden email]
> Institut fuer Allgemeine Physik, Technische Universitaet Wien
> Wiedner Hauptstr. 8-10/134, A 1040 Wien, Austria
> Tel. +43 1 58801-13452 or -13453, Fax +43 1 58801 13499
> ________________________________________________________________
>
> On 4 Sep 2008, at 16:04, Nick Holway wrote:
>
>  Hi,
>>
>> I'm trying to write a macro which puts a scale bar on all the images in a
>> directory. I've borrowed bits from the Bacth Convert macro.
>>
>> run("Set Scale...", "distance=1 known=1 pixel=1 unit=um");
>> dir1 = "C:\\imagejdev\\original\\";
>> dir2 = "C:\\imagejdev\\output\\";
>>  list = getFileList(dir1);
>>  setBatchMode(true);
>>  for (i=0; i<list.length; i++) {
>>  showProgress(i+1, list.length);
>>  open(dir1+list[i]);
>> run("Scale Bar...", "width=100 height=5 font=18 color=Black
>> background=None
>> location=[Lower Right] bold");
>>  saveAs("TIFF", dir2+list[i]);
>>  close();
>>  }
>>
>> I have a couple of problems with this:
>>
>> * If there is no image open, then a dialog warns you of this
>>
>> * If the macro opens a JPEG then the scrip works properly, if it opens a
>> tif
>> then the scale line extends from the LHS of the image to the RHS of where
>> it
>> should end
>>
>> I'm using the v1.41 of the MBF build on Windows XP SP2 and I also tried
>> Imagej 1.41 with the MBF plugins on Centos 5.2. I had the same problems on
>> both platforms. FWIW the files were originally created under Windows.
>>
>> Does anyone know how to get around these problems?
>>
>> Thanks
>>
>> Nick
>>
>