NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug.

The Fiji project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Bug 1032 - I'm trying to merge two images (1 gb each, tiff files) and Image J processess the top half of the image while the bottom is black.
I'm trying to merge two images (1 gb each, tiff files) and Image J processess...
Status: RESOLVED FIXED
Product: Fiji
Classification: Unclassified
Component: ImageJ1
unspecified
PC Windows
: P5 blocker
Assigned To: ImageJ Bugs Mailing List
Depends on:
Blocks:
 
Reported: 2015-03-19 18:23 CDT by niladri
Modified: 2015-04-06 15:54 CDT
3 users (show)

See Also:


Attachments
Screenshot of merge error (1.03 MB, image/png)
2015-03-19 18:23 CDT, niladri
Update on ImageJ merge error (637.46 KB, image/jpeg)
2015-03-23 13:29 CDT, niladri
Screenshot showing merge macro output on OS X (159.50 KB, image/png)
2015-03-23 22:44 CDT, Wayne Rasband
Update on ImageJ merge error-2 (700.35 KB, image/png)
2015-03-24 12:21 CDT, niladri

Description niladri 2015-03-19 18:23:42 CDT
Created attachment 241
Screenshot of merge error

Additional information:

o	ImageJ version - Fiji
o	OS version - Windows 7
o	Java version (shown in Help/About ImageJ) - Latest
o	Memory assigned to ImageJ (Edit/Options/Memory) System memory. Assigned to ImageJ 15-20 GB
o	Any error messages - No error messages, just incorrect merging
o	Steps needed to reproduce the problem - This is reproducible on multiple machines. When the size of image drops to 450 MB, ImageJ is able to merge correctly.

Please advise!
Comment 1 Wayne Rasband 2015-03-19 19:34:33 CDT
How much RAM does you machine have? It should 24GB or more if you are assigning 20GB to ImageJ. My 5 year old Mac laptop with 8GB of RAM cannot cope with 1GB images.
Comment 2 niladri 2015-03-19 20:15:51 CDT
Thank you for your reply. Yes, it is a 24 GB desktop. I've tried it previously with a 16 Gb desktop as well with designating 14 Gb to ImageJ. Thanks!
Comment 3 Wayne Rasband 2015-03-19 20:38:17 CDT
Try using Java 8. I just did some testing and found it handles 1GB images much better than Java 6. I run ImageJ with Java 8 on my Mac by changing to the ImageJ directory and using this command:

    java -Xmx7g -jar ij.jar

Or this FAQ describes how to run Fiji using a different version of Java:

http://fiji.sc/Frequently_Asked_Questions#How_do_I_launch_ImageJ_with_a_different_version_of_Java.3F
Comment 4 niladri 2015-03-20 16:34:36 CDT
I just tried merging by updating to Java 8 and have the same issue. No noticable changes. Hoping to resolve it!
Comment 5 niladri 2015-03-23 13:29:57 CDT
Created attachment 242
Update on ImageJ merge error
Comment 6 niladri 2015-03-23 13:31:38 CDT
Comment on attachment 242
Update on ImageJ merge error

This was run on a dektop with 18GB of 24 GB RAM allocated to ImageJ. Latest version of JAVA.
Comment 7 Wayne Rasband 2015-03-23 22:44:27 CDT
Created attachment 243
Screenshot showing merge macro output on OS X
Comment 8 Wayne Rasband 2015-03-23 23:11:12 CDT
Does the following test macro work as expected on your system? I attached a screenshot that shows what the merged image created by the macro should look like. Before running the macro, you should upgrade to the latest ImageJ daily build (1.49q15). It fixes a bug that caused extremely large images (e.g., 30000x30000) to not be displayed correctly because the minimum magnification was 3.1%. Also, the "Merge Channels" command now deletes the source images only after displaying the composite image. To upgrade, use the Help>Update ImageJ command and select "daily build" from the drop down menu. 

    MB = 850;
    w = sqrt(MB*1024*1024);
    doCommand("Monitor Memory...");
    newImage("c1", "8-bit ramp", w, w, 1);
    newImage("c2", "8-bit ramp", w, w, 1);
    run("Rotate 90 Degrees Right");
    run("Merge Channels...", "c1=c1 c2=c2 create");
Comment 9 niladri 2015-03-24 12:21:11 CDT
Created attachment 244
Update on ImageJ merge error-2

Thanks so much for your help on this. I have followed your instructions and run the macro; however, the same error persists (attached screenshot). Not sure if this is a windows error. Please advise.
Comment 10 Wayne Rasband 2015-03-24 20:07:03 CDT
I am able to duplicate this problem, using images larger than 500 megapixels, on both Mac and Windows machines. It is a problem only with the way images are displayed, so the pixel data is not corrupted. This appears to be a Java bug so it is not something I can fix. You should be able to work around the problem by either scaling your images to 500 megapixels or less or by processing and analyzing the images at full size and then scaling to screen size to view the results. By the way, I observed many JVM crashes, on both Macs and Windows, while working with 500+ megapixel images.
Comment 11 niladri 2015-03-25 11:48:16 CDT
Thanks. Is there way to scale down both channels in imageJ so that they remain the same size? I tried saving each channel as a JPEG but they end up being different sizes and can't be merged.
Comment 12 Wayne Rasband 2015-03-25 12:59:18 CDT
The following example macro creates two 850 megapixel images, merges them, scales the merged image to 2048x2048, saves it as JPEG and displays it. It does this without displaying any of the 850 megapixel images. The resulting JPEG file is 137K.  

    MB = 850;
    setBatchMode(true);
    w = sqrt(MB*1024*1024);
    doCommand("Monitor Memory...");
    newImage("c1", "8-bit ramp", w, w, 1);
    newImage("c2", "8-bit ramp", w, w, 1);
    run("Rotate 90 Degrees Right");
    run("Merge Channels...", "c1=c1 c2=c2");
    run("Size...", "width=2048 height=2048 constrain interpolation=Bilinear");
    saveAs("Jpeg", "");
    setBatchMode(false);

This version of the macro saves the 850 megapixel merged image as a 15MB (29,854x29,854) JPEG without displaying anything.

    MB = 850;
    setBatchMode(true);
    w = sqrt(MB*1024*1024);
    doCommand("Monitor Memory...");
    newImage("c1", "8-bit ramp", w, w, 1);
    newImage("c2", "8-bit ramp", w, w, 1);
    run("Rotate 90 Degrees Right");
    run("Merge Channels...", "c1=c1 c2=c2");
    saveAs("Jpeg", "");
Comment 13 niladri 2015-03-25 14:38:34 CDT
Thank you very much. I apologize for the unfamiliarity with macros. How do I change the macro you provided so that it uses my two image files (i.e. the two channels) for merging? Also, how do I assig the desired colors using this macro?
Comment 14 Wayne Rasband 2015-03-26 15:49:28 CDT
You can use the open() function to open images and you can run commands in the Image>Lookup Tables menu to assign colors to the channels. Here is an example:

    open("");
    rename("c1");
    open("");
    rename("c2");
    run("Merge Channels...", "c1=c1 c2=c2 create");
    run("Blue");
    setSlice(2);
    run("Yellow");

The command recorder (Plugins>Macros>Record) is helpful for creating macro code.
Comment 15 niladri 2015-03-26 15:52:29 CDT
Thanks for your support on this!