[ome-devel] RenderingEngine: setting channel colours

Will Moore will at lifesci.dundee.ac.uk
Thu Mar 22 13:03:52 GMT 2012


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20120322/9645210d/attachment-0001.html>


More information about the ome-devel mailing list