[ome-devel] RenderingEngine: setting channel colours

Jerome Avondo jeromeavondo at msn.com
Thu Mar 22 17:13:56 GMT 2012


Ignore the "omero::OptimisticLockException"  error, I had some code downstream that was causing the exception.No more exceptions now, but still not setting the channel colours ...
J.

From: jeromeavondo at msn.com
To: will at lifesci.dundee.ac.uk
Date: Thu, 22 Mar 2012 15:21:22 +0000
CC: ome-devel at lists.openmicroscopy.org.uk
Subject: Re: [ome-devel] RenderingEngine: setting channel colours







Apologies I meant this thread:http://www.openmicroscopy.org/community/viewtopic.php?f=6&t=694 
J.
From: jeromeavondo at msn.com
To: will at lifesci.dundee.ac.uk
Date: Thu, 22 Mar 2012 15:18:54 +0000
CC: ome-devel at lists.openmicroscopy.org.uk
Subject: Re: [ome-devel] RenderingEngine: setting channel colours







Hi Will,
Thanks for the info...I saw that thread, but kept getting an "omero::OptimisticLockException" when trying that approach...
So I was following this thread, since it helped greatly to allow me to upload data...https://www.openmicroscopy.org/community/viewtopic.php?f=6&t=768
Just to make sure I understand the difference between setting channel colours via the RenderingEngine vs Channel objects....The RenderingEngine is a per user setting, whilst doing it on the Channel object will make it the default for all users?
Using your code, I changed mine to the following, however I still get the "omero::OptimisticLockException"... 
        std::string query = "select p from Pixels p join fetch p.channels as c join fetch c.logicalChannel as lc where p.id=:pid";        omero::sys::ParametersIPtr params = new omero::sys::ParametersI();	params->add("pid", omero::rtypes::rlong(pixid));	omero::api::IObjectList resultobjs = queryService->findAllByQuery(query, params);	if(resultobjs.empty()) 	{		printf("ERROR: Could not find pixels object\n");		return;	}
	pixels = omero::model::PixelsPtr::dynamicCast(resultobjs[0]);	for(int c=0; c<csize; c++)	{		omero::model::ChannelPtr chan = pixels->getChannel(c);		omero::model::IObjectPtr obj = queryService->get("Channel", chan->getId()->getValue());		chan = omero::model::ChannelPtr::dynamicCast(obj);			chan->setRed(omero::rtypes::rint(0));		chan->setGreen(omero::rtypes::rint(255));		chan->setBlue(omero::rtypes::rint(0));		chan->setAlpha(omero::rtypes::rint(255));		gateway->saveObject(chan);	}       sf->getDeleteService()->deleteSettings(imageID);
Any idea what I'm doing wrong?Thanks!
J.
Subject: Re: [ome-devel] RenderingEngine: setting channel colours
From: will at lifesci.dundee.ac.uk
Date: Thu, 22 Mar 2012 13:03:52 +0000
CC: jeromeavondo at msn.com; ome-devel at lists.openmicroscopy.org.uk
To: will at lifesci.dundee.ac.uk



Hi Jerome,
You can also see this discussed on our forums (Python again I'm afraid)
https://www.openmicroscopy.org/community/viewtopic.php?f=6&t=768
which was the first hit when I Googled:omero forum setting channel colours
Cheers,
  Will. 


On 22 Mar 2012, at 13:00, Will Moore wrote:Hi Jerome,
The best way of doing this is to set the colours on the Channels themselves, then reset the default rendering settings.This means that whenever any user resets their rendering settings on the image, they will default to the 'correct' colours. 
Here's some (pseudo code) of what I'm doing in Python - Hopefully you can work out the C++Not sure if you'll have to reload as I'm doing. Try it and see.
You can get channels via pixels,EITHER via the rendering engine (once you've set Ids etc)...
pixels  = re.getPixels()

OR via the query service...
pid = image.getPrimaryPixels().getId().getValue()params = omero.sys.Parameters()params.map = {"pid": rlong(pid)}query = "select p from Pixels p join fetch p.channels as c join fetch c.logicalChannel as lc where p.id=:pid"pixels = session.getQueryService().findByQuery(query, params)
for c in pixels.iterateChannels():	# ??? need to reload channels to avoid optimistic lock on update ??? 
        c = conn.getQueryService().get("Channel", c.id.val)	# could try to skip this step
	c.red = omero.rtypes.rint(r)	c.green = omero.rtypes.rint(g)	c.blue = omero.rtypes.rint(b)	c.alpha = omero.rtypes.rint(255)	session.getUpdateService().saveObject(c)

Than reset session.getDeleteService().deleteSettings(imageId)
If this doesn't work, maybe also try:renderingEngine.resetDefaults()

 Let us know how you get on,

   Will


On 22 Mar 2012, at 12:11, Jerome Avondo wrote:Hi,
I am trying to set the rendering colours for an image I upload to the server via the C++ API...The image upload is all good, but I am a little confused with setting the rendering options...I am uploading a 3 channel image, and I set the render settings as follows:
	for(int c=0; c<csize; c++)	{		if(c==0)		{			renderingEngine->setChannelWindow(c, float(0), float(255));			renderingEngine->setRGBA(c, 255, 0, 0, 255);		}		if(c==1)		{			renderingEngine->setChannelWindow(c, float(0), float(255));			renderingEngine->setRGBA(c, 0, 255, 0, 255);		}		if(c==2)		{			renderingEngine->setChannelWindow(c, float(0), float(255));			renderingEngine->setRGBA(c, 0, 0, 255, 255);		}	}
	renderingEngine->saveCurrentSettings();Basically I want my 3 channel image to be red, green, blue....However the first two channels appear as white, whilst only the last is blue... I tried moving the saveCurrentSettings() after each channel call, but no joy.I'm sure it's something simple, but can't figure it out... Thanks in advance,
Jerome._______________________________________________
ome-devel mailing list
ome-devel at lists.openmicroscopy.org.uk
http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel

_______________________________________________
ome-devel mailing list
ome-devel at lists.openmicroscopy.org.uk
http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel

 		 	   		  

_______________________________________________
ome-devel mailing list
ome-devel at lists.openmicroscopy.org.uk
http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel 		 	   		  

_______________________________________________
ome-devel mailing list
ome-devel at lists.openmicroscopy.org.uk
http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20120322/42896234/attachment.html>


More information about the ome-devel mailing list