Re: problems with Batch Converter

Posted by ctrueden on
URL: http://imagej.273.s1.nabble.com/problems-with-Batch-Converter-tp5002705p5002765.html

Hi Lars,

> Only thing now is that the brightness of the resulting JPG's is lower
> than if I view the original in AxioVision.

Perhaps AxioVision is autoscaling your display range. You could try adding
the "autoscale" flag to the "Bio-Formats Importer" command in your ImageJ
macro:

    run("Bio-Formats Importer", "open='" + inBase + path + "'
        color_mode=Composite view=[Hyperstack] stack_order=Default
autoscale");

The above sets the displayed minimum and maximum values to match those of
the data itself.

Alternately, you could do something like:

    run("Enhance Contrast", "saturated=0.35");

Which gives you more control over what percentage of pixels fall outside
the bounds of the displayed min/max.

Regards,
Curtis


On Mon, Apr 22, 2013 at 7:57 AM, Lars Riis Damgaard <[hidden email]>wrote:

> Thanks Curtis, that did brought colors. Only thing now is that the
> brightness of the resulting JPG's is lower than if I view the original in
> AxioVision. I wonder which is 'correct'?
> Lars
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Curtis Rueden
> Sent: 19. april 2013 16:48
> To: [hidden email]
> Subject: Re: problems with Batch Converter
>
> Hi Lars,
>
> > Only thing now seems to be that my JPGs come in B/W instead of color
> > like the source ZVIs.
>
> Probably your source ZVIs store channels as separate planes, so they open
> as a composite color image, rather than an RGB color one.
>
> > Any suggestions to solve that also (present code is below)?
>
> Sure, you can try adjusting the opening step to do something like:
>
>     run("Bio-Formats Importer", "open='" + inBase + path + "'
>         color_mode=Composite view=[Hyperstack] stack_order=Default");
>     run("RGB Color");
>
> That will open the file as a hyperstack in composite color mode, then
> convert to RGB color before exporting as JPEG.
>
> > PS.  I read about ImageJ2 now and then - when is it due?
>
> It is in beta now, meaning lots of stuff works but there are technical
> aspects that are still subject to change. You can download and try it from
> http://developer.imagej.net/downloads. That page also has the release
> schedule.
>
> > PPS. Is there a way to halt processes and macros in ImageJ (like
> > Ctrl-Break in some programs)?
>
> Not that I know of, other than quitting ImageJ. However, if you control
> the macro code, you could always build in a way to cancel it mid-execution.
>
> Regards,
> Curtis
>
>
> On Fri, Apr 19, 2013 at 9:06 AM, Lars Riis Damgaard <[hidden email]
> >wrote:
>
> > Hi Curtis,
> >
> > Thanks a lot. I played a bit with it, and I seem to be doing some
> > progress. In addition to changing file extensions, I had to remove the
> > uppercasing of the path before it gave results. Only thing now seems
> > to be that my JPGs come in B/W instead of color like the source ZVIs.
> > Any suggestions to solve that also (present code is below)?
> >
> > Lars
> >
> > PS.  I read about ImageJ2 now and then - when is it due?
> > PPS. Is there a way to halt processes and macros in ImageJ (like
> > Ctrl-Break in some programs)?
> >
> > CODE:
> > ____________________________________________________________
> >
> > ext = "zvi"; // this variable controls the extension of source files
> >
> > requires("1.39u");
> > inDir = getDirectory("Choose Directory Containing " + ext + " Files
> > "); outDir = getDirectory("Choose Directory for JPG Output ");
> > setBatchMode(true); processFiles(inDir, outDir, "");
> > print("-- Done --");
> >
> > function processFiles(inBase, outBase, sub) {
> >   flattenFolders = true; // this flag controls output directory structure
> >   print("-- Processing folder: " + sub + " --");
> >   list = getFileList(inBase + sub);
> >   if (!flattenFolders) File.makeDirectory(outBase + sub);
> >     for (i=0; i<list.length; i++) {
> >     path = sub + list[i];
> >     //upath = toUpperCase(path);
> >     upath = path; // should not be upper-cased as line above does
> >     if (endsWith(path, "/")) {
> >       // recurse into subdirectories
> >       processFiles(inBase, outBase, path);
> >     }
> >    else if (endsWith(upath, "." + ext)) {
> >       print("-- Processing file: " + path + " --");
> >       run("Bio-Formats Importer", "open='" + inBase + path + "'
> > color_mode=Default view=[Standard ImageJ] stack_order=Default
> > use_virtual_stack");
> >       outFile = outBase + path + ".jpg";
> >       if (flattenFolders) outFile = replace(outFile, "/", "_");
> >       run("Bio-Formats Exporter", "save=[" + outFile + "]
> > compression=Uncompressed");
> >       close();
> >       run("Collect Garbage");
> >     }
> >   }
> > }
> >
> >
> > -----Original Message-----
> > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> > Curtis Rueden
> > Sent: 18. april 2013 21:49
> > To: [hidden email]
> > Subject: Re: problems with Batch Converter
> >
> > Hi Lars,
> >
> > > In the end, no matter if I OK or cancel any of the dialogs, some
> > > open files are created in ImageJ, but my output folder is empty.
> >
> > You have run into a limitation of the way ImageJ's image I/O works. In
> > this case, the symptom is that Batch Converter will not work when
> > reading files using Bio-Formats.
> >
> > ImageJ2 will make image I/O more extensible, but in the meantime, the
> > easiest solution is to convert your files using a macro.
> >
> > Here is a template you can adapt to do what you want:
> >
> > https://github.com/openmicroscopy/bioformats/blob/v4.4.6/components/lo
> > ci-plugins/utils/macros/recursiveTiffConvert.txt
> >
> > Change the "DM3" extension to "ZVI" and then change the ".ome.tif"
> > extension on line 38 to ".jpg" instead.
> >
> > Let us know if you have any trouble with it!
> >
> > Regards,
> > Curtis
> >
> >
> > On Thu, Apr 18, 2013 at 3:17 AM, Lars Damgaard <[hidden email]>
> wrote:
> >
> > > Hi all,
> > >
> > > I hope someone can help me understand this:
> > > I have a folder with 40 zvi files that I want to convert to jpg files.
> > > I figure from searching documentation that I should use Batch
> > > Converter. When I select Batch Converter, I get a Batch Convert
> > > dialog as expected that allows me to select input and output folder,
> > > Output format, Interpolation, and Scale factor.
> > > However, when I press the Convert button, I get a Bio-Formats Import
> > > Options dialog, which has a lot of options.
> > > If I try to choose options and press OK, this dialog is followed by
> > > a Bio-Formats File Stitching dialog.
> > > If I OK this File Stitching dialog, I can see in the status bar that
> > > ImageJ apparently is working its way through all files, but then the
> > > Bio-Format Import Options dialog re-appears, followed by the
> > > Bio-Formats File Stitching dialog. Depending on my choices I also
> > > get an Import Data dialog. For each file, I get a log window that
> writes:
> > > IJ.openImage() returned null:
> > > C:\Users\lrd\Desktop\zvi-files\Position(1).zvi
> > > IJ.openImage() returned null:
> > > C:\Users\lrd\Desktop\zvi-files\Position(10).zvi
> > > ...
> > > etc.
> > > In the end, no matter if I OK or cancel any of the dialogs, some
> > > open files are created in ImageJ, but my output folder is empty. I
> > > have not managed to make my selections so that the open created
> > > files are the simple jpg files I want, rather they are separated out
> > > in color channels or other advanced views, but in any case I was
> > > expecting that the zvi files were batch converted and the resulting
> > > jpgs would go to
> > the output folder.
> > > Any suggestions as to how to achieve this?
> > >
> > > Lars
> > >
> > > --
> > > 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
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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