Open zunbeltz opened 9 years ago
@zunbeltz Hmm, I'm not completely sure. It turns out that I've been playing with the AreaDetector image display code, and trying to update it. So, I'll try to look into this over the next couple days... I suspect that what may be needed is approximately
# default mode and size
im_mode = 'L'
im_size = (arrsize[0], arrsize[1])
dsize = arrsize[0]*arrsize[1]
if colormode == 2: # color image
im_mode = 'RGB'
im_size = (arrsize[1], arrsize[2])
dsize *= arrsize[2]
rawdata = ad_img.PV('ArrayData').get(count=dsize)
if (colormode == 0 and isinstance(rawdata, np.ndarray) and
rawdata.dtype != np.uint8):
im_mode = 'I'
rawdata = rawdata.astype(np.uint32)
if im_mode in ('L', 'I'):
wximage = wx.EmptyImage(width, height)
imbuff = Image.frombuffer(im_mode, im_size, rawdata,
'raw', im_mode, 0, 1)
wximage.SetData(imbuff.convert('RGB').tostring())
elif im_mode == 'RGB':
rawdata = rawdata.astype(np.uint32)
rawdata.shape = (3, width, height)
wximage = wx.ImageFromData(width, height, rawdata)
wximage = wximage.Scale(int(scale*width), int(scale*height))
but that is not actually tested. Again, I'll try this out over the next couple days....
@newville Just updating to the last commits has solved the problem here. Thanks.
@zunbeltz -- Glad it works! Can you clarify whether you mean the most recent version of the code works, or was the code snippet I posted needed?
I made a new clone of the project which includes commits from yesterday. I did not need to ise the code snippet. El 11/06/2015 14:08, "Matt Newville" notifications@github.com escribió:
@zunbeltz https://github.com/zunbeltz -- Glad it works! Can you clarify whether you mean the most recent version of the code works, or was the code snippet I posted needed?
— Reply to this email directly or view it on GitHub https://github.com/pyepics/epicsapps/issues/14#issuecomment-111109317.
Dear Matt,
I would like to customise the AreaDetector application to do some image processing "on the fly." At the moment the application connects to the camera and the "acquisition start/stop" works properly. Unfortunately the image is not show in the frame (just black). I looked to the code and I think that this is due to the fact that my raw data is of type uint16 and mono. In this case
ad_display.py
lines 866--876, setsim_mode
to'I'
and convert to uint32. But in theDataToImage
method I couldn't find the code lines that convert the data to an image. As far as I understand from the documentation neither the python Image library 'image.frombuffernor 'wx.ImageFromData
support this kind of data. Am I correct? Does this mean that the only way to go is to scale down the rawdata to uint8? or is there other ways to plot the uint16 data?Thanks
ps. I used some
print
statement, so the line numbers above may be a bit shifted.