problem with Merge Channels and renaming

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

problem with Merge Channels and renaming

Cammer, Michael
I'm having a problem with renaming an image after using run("Merge Channels..." with ImageJ 1.51o (which according to the update command in the help menu is the daily build) and both Java 1.6 and 1.8.



In the macro below, at the end an image that is not the result of the Merge Channels gets renamed.  If the only other wndow open is the original, then the original is renamed.



Help appreciated.



Regards,

Michael




/==================================
macro "Proper Eq of RGB per channel" {
  //original = getImageID;
  title = getTitle;
  run("Duplicate...", "title=temp");
  run("Split Channels");
  selectWindow("temp (blue)");
  run("Enhance Contrast...", "saturated=0 equalize");
  selectWindow("temp (green)");
  run("Enhance Contrast...", "saturated=0 equalize");
  selectWindow("temp (red)");
  run("Enhance Contrast...", "saturated=0 equalize");
  run("Merge Channels...", "c1=[temp (red)] c2=[temp (green)] c3=[temp (blue)]");
  rename("EQ_" + title);
}



_________________________________________
Michael Cammer, Optical Microscopy Specialist
http://ocs.med.nyu.edu/microscopy
http://microscopynotes.com/
Cell: (914) 309-3270

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem with Merge Channels and renaming

PEARSON Matthew
Hi Michael,

I think you're right that the active image should be the merge but to get around this you could use selectWindow (); to try to force the merge to be active? I realise this would only be a temporary workaround if it works!

Thanks,

Matt


-------- Original message --------
From: "Cammer, Michael" <[hidden email]>
Date: 07/06/2017 02:19 (GMT+00:00)
To: [hidden email]
Subject: problem with Merge Channels and renaming

I'm having a problem with renaming an image after using run("Merge Channels..." with ImageJ 1.51o (which according to the update command in the help menu is the daily build) and both Java 1.6 and 1.8.



In the macro below, at the end an image that is not the result of the Merge Channels gets renamed.  If the only other wndow open is the original, then the original is renamed.



Help appreciated.



Regards,

Michael




/==================================
macro "Proper Eq of RGB per channel" {
  //original = getImageID;
  title = getTitle;
  run("Duplicate...", "title=temp");
  run("Split Channels");
  selectWindow("temp (blue)");
  run("Enhance Contrast...", "saturated=0 equalize");
  selectWindow("temp (green)");
  run("Enhance Contrast...", "saturated=0 equalize");
  selectWindow("temp (red)");
  run("Enhance Contrast...", "saturated=0 equalize");
  run("Merge Channels...", "c1=[temp (red)] c2=[temp (green)] c3=[temp (blue)]");
  rename("EQ_" + title);
}



_________________________________________
Michael Cammer, Optical Microscopy Specialist
http://ocs.med.nyu.edu/microscopy
http://microscopynotes.com/
Cell: (914) 309-3270

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================

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

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

The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem with Merge Channels and renaming

gnelson
In reply to this post by Cammer, Michael
Hi Michael,

Matt is correct: if you insert:

selectWindow("RGB");

after the run merge channels line it will work.

I usually add this line before running image processing if I have other windows open just to ensure I am working with the correct image.  As to why it isn't choosing the last processed window, I don't know!  I think you can give a title to the merged image within the Merge Channels command, but I can't remember how to do this.  

Alternatively, you could remove the Duplicate command and add a line to rename the image to temp:
-------
macro "Proper Eq of RGB per channel" {
  //original = getImageID;
  title = getTitle;
  rename("temp");
//  run("Duplicate...", "title=temp");
  run("Split Channels");
  selectWindow("temp (blue)");
  run("Enhance Contrast...", "saturated=0 equalize");
  selectWindow("temp (green)");
  run("Enhance Contrast...", "saturated=0 equalize");
  selectWindow("temp (red)");
  run("Enhance Contrast...", "saturated=0 equalize");
  run("Merge Channels...", "c1=[temp (red)] c2=[temp (green)] c3=[temp (blue)]");

// selectWindow("RGB");
  rename("EQ_" + title);
}
-----
Then there is only one image open so this is the active window.

As an aside, out of sheer curiosity, I thought it would be less computer intensive to convert the RGB to a stack and then select the channels rather than creating separate images, like so:

macro "Proper Eq of RGB per channel" {
  //original = getImageID;
  title = getTitle;
  run("RGB Stack");
  Stack.setSlice(1);
  run("Enhance Contrast", "saturated=0 equalize");
  Stack.setSlice(2);
  run("Enhance Contrast", "saturated=0 equalize");
  Stack.setSlice(3);
  run("Enhance Contrast", "saturated=0 equalize");
  run("RGB Color");
  rename("EQ_" + title);
}

But this gives a different result!  And it is different to the result obtained if you just open the rgb and run the enhanced contrast on that.  I have no idea why.

Glyn.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem with Merge Channels and renaming

Cammer, Michael
In reply to this post by PEARSON Matthew
Actually, the problem is worse than that.  To do things to the result window after the macro stops, I need to click on the image twice or else the first time doing an operation returns an error that an image needs to be selected.

=*===========================================================*=
 Michael Cammer, DART Microscopy Laboratory, NYU Langone Medical Center
    Cell:  914-309-3270 (this is for calling, not texting)    Office: Skirball 2nd Floor main office, back right
      http://ocs.med.nyu.edu/microscopy & http://microscopynotes.com/



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of PEARSON Matthew
Sent: Wednesday, June 07, 2017 2:36 AM
To: [hidden email]
Subject: Re: problem with Merge Channels and renaming

Hi Michael,

I think you're right that the active image should be the merge but to get around this you could use selectWindow (); to try to force the merge to be active? I realise this would only be a temporary workaround if it works!

Thanks,

Matt


-------- Original message --------
From: "Cammer, Michael" <[hidden email]>
Date: 07/06/2017 02:19 (GMT+00:00)
To: [hidden email]
Subject: problem with Merge Channels and renaming

I'm having a problem with renaming an image after using run("Merge Channels..." with ImageJ 1.51o (which according to the update command in the help menu is the daily build) and both Java 1.6 and 1.8.



In the macro below, at the end an image that is not the result of the Merge Channels gets renamed.  If the only other wndow open is the original, then the original is renamed.



Help appreciated.



Regards,

Michael




/==================================
macro "Proper Eq of RGB per channel" {
  //original = getImageID;
  title = getTitle;
  run("Duplicate...", "title=temp");
  run("Split Channels");
  selectWindow("temp (blue)");
  run("Enhance Contrast...", "saturated=0 equalize");
  selectWindow("temp (green)");
  run("Enhance Contrast...", "saturated=0 equalize");
  selectWindow("temp (red)");
  run("Enhance Contrast...", "saturated=0 equalize");
  run("Merge Channels...", "c1=[temp (red)] c2=[temp (green)] c3=[temp (blue)]");
  rename("EQ_" + title);
}



_________________________________________
Michael Cammer, Optical Microscopy Specialist http://ocs.med.nyu.edu/microscopy https://urldefense.proofpoint.com/v2/url?u=http-3A__microscopynotes.com_&d=DQIFAw&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=M69Y9Gke41XnqN9Sp7h6PpvnQqDcwwFHASmooE1l0lQ&s=2LmX0tW7RJXPLG_h9LWVsn5ORIfI7zOp3-6mFA8MMfM&e=
Cell: (914) 309-3270

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================

--
ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=DQIFAw&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=M69Y9Gke41XnqN9Sp7h6PpvnQqDcwwFHASmooE1l0lQ&s=QxpSVd0tXqEN8N8oMwbqUL_MNzSCSD187e2N_ARy0ZQ&e= 

--
ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=DQIFAw&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=M69Y9Gke41XnqN9Sp7h6PpvnQqDcwwFHASmooE1l0lQ&s=QxpSVd0tXqEN8N8oMwbqUL_MNzSCSD187e2N_ARy0ZQ&e= 

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem with Merge Channels and renaming

Wayne Rasband-2
In reply to this post by Cammer, Michael
> On Jun 6, 2017, at 9:18 PM, Cammer, Michael <[hidden email]> wrote:
>
> I'm having a problem with renaming an image after using run("Merge Channels..." with ImageJ 1.51o (which according to the update command in the help menu is the daily build) and both Java 1.6 and 1.8.
>
> In the macro below, at the end an image that is not the result of the Merge Channels gets renamed.  If the only other wndow open is the original, then the original is renamed.


This bug is fixed in the latest ImageJ daily build (1.51o35). Or work around it by using batch mode, by adding selectImage("RGB”) before the last line in the macro, or by not using "Merge Channels", as in the the following example.

-wayne

  run("Leaf (36K)");
  run("RGB Stack");
  for (i=1; i<=3; i++) {
     setSlice(i);
     run("Enhance Contrast...", "saturated=0 equalize");
  }  run("RGB Color");
  rename("EQ_" + getTitle);


> /==================================
> macro "Proper Eq of RGB per channel" {
>  //original = getImageID;
>  title = getTitle;
>  run("Duplicate...", "title=temp");
>  run("Split Channels");
>  selectWindow("temp (blue)");
>  run("Enhance Contrast...", "saturated=0 equalize");
>  selectWindow("temp (green)");
>  run("Enhance Contrast...", "saturated=0 equalize");
>  selectWindow("temp (red)");
>  run("Enhance Contrast...", "saturated=0 equalize");
>  run("Merge Channels...", "c1=[temp (red)] c2=[temp (green)] c3=[temp (blue)]");
>  rename("EQ_" + title);
> }

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