multispectral imaging: rgb image
Dear all, Is there something available in scikits-image to produce a rgb image from a 4 or more channels multispectral<http://dip4fish.blogspot.com/2011/05/mfish-image-to-rgb-with-image5d.html>image? Thanks Jean-Patrick
Hi Jean-Patrick On Thu, May 19, 2011 at 4:19 PM, jip <jeanpatrick.pommier@gmail.com> wrote:
Is there something available in scikits-image to produce a rgb image from a 4 or more channels multispectral image?
We don't have any specific false-colour mappings implemented; these are typically problem dependent. It should be trivial to make such a mapping, though. See if you can find more information on the specific one used in your example, then we can give you a hand. Regards Stéfan
Hi Stéfan, The following script try to produce a rgb image from a five channels image (with the grey images from my blog<http://dip4fish.blogspot.com/2011/05/mfish-image-to-rgb-with-image5d.html>, converted to png:FarRed, Red, Gold, Green, Aqua(blue)). It fails with error: red=c3_r.reshape(c3,shape) TypeError: only length-1 arrays can be converted to Python scalars The other issue is how to choose the coef of the matrix m such that the colors are "well separated". In the HSV space<http://en.wikipedia.org/wiki/HSL_and_HSV>, I suppose it is possible to choose the coef such that the colors are separated by 2pi/5 in the hue component,starting with FarRed=0°. *import numpy as np import readmagick import os user=os.path.expanduser("~") workdir=os.path.join(user,"Applications","ImagesTest","MFISH") blue="Aqua.tif" green="Green.tif" gold="Gold.tif" red="Red.tif" frd="FarRed.tif" complete_path=os.path.join(workdir,blue) i1=readmagick.readimg(complete_path) # complete_path=os.path.join(workdir,green) i2=readmagick.readimg(complete_path) # complete_path=os.path.join(workdir,gold) i3=readmagick.readimg(complete_path) # complete_path=os.path.join(workdir,red) i4=readmagick.readimg(complete_path) # complete_path=os.path.join(workdir,frd) i5=readmagick.readimg(complete_path) # shape=i5.shape print shape b=i1.flatten() g=i2.flatten() y=i3.flatten() r=i4.flatten() f=i5.flatten() #make a 2D array #each line is a pixel, column=channel channel5=np.vstack((f,r,y,g,b)) c5=channel5.T print c5.shape #try some coef m=np.array([[0.0, 0.02, 0.80], [0.0, 0.03, 0.10], [0.10, 0.05, 0.05], [0.10, 0.80, 0.04], [0.80, 0.10, 0.01]]) print m.shape #produce a flat rgb image c3=np.dot(c5,m) print "c3:",c3.shape c3_r=c3[:,0] print "c3_r:",c3_r.shape,c3_r.dtype c3_g=c3[:,1] c3_b=c3[:,2] print c3_r.shape red=c3_r.reshape(c3,shape)#should be a red image green=c3_g.reshape(c3,shape) blue=c3_b.reshape(c3,shape) import pylab pylab.imshow(red) pylab.show* Best regards Jean-Patrick
participants (2)
-
jip
-
Stéfan van der Walt