EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: [Scopes] BMP image record??
From: Pavel Masloff <[email protected]>
To: Matt Newville <[email protected]>
Cc: EPICS Tech Talk <[email protected]>
Date: Tue, 1 May 2012 00:20:33 +0400
Hey Matt,

Thanks for sharing! I can't make your code work, though. Every time I get some gibberish image, You might have forgotten to convert int to string?
I am using the following script.
Image file -> waveform:

import Image
import StringIO

from epics import PV
f = open('hello.bmp')     #source image file
data = "">
chan = PV ('file')
chan.put(data)

Waveform -> image file:

import os, sys
import Image
import StringIO
from epics import PV

chan = PV ('file')     #waveform pv
data = "" #waveform.val

sdata = ''.join(chr(x) for x in data)      
sfile = StringIO.StringIO(sdata)
im = Image.open(sfile)
im.save("yoyo.bmp")
im.show()


Another thing I can't understand - the Intensity widget in BOY. I don't know how to set its properties. I set PV name, Data height, Data width, Max, Min. And get an ugly image.

Could you also explain to me how the trasformation image binary file -> waveform and back happens? As I understand an image is roughly a set of pixels each with its own color. There is also a header (which we don't need?) Then we read the file and forward every byte into the waveform record which is of type unsigned char (integers 0-255) with a size = 1byte. So in order to get an image out of the waveform we should break the waveform N times with an interval M (if our image dimensions are N*M). There is also a Color map which specifies what color our integers equal to.
Now when we want to convert our waveform back to file we are using the chr(x) function, I don't know why.

Next thing as you mentioned is the NELM field and EPICS_CA_MAX_ARRAY_BYTE variable. So if our image is say 400*300 24 bit BMP image, does it mean we should set NELM=400*300 and EPICS_CA_MAX_ARRAY_BYTE=400*300*24?

I would be grateful to hear your comments.
Thank you.

Pavel



On Mon, Apr 30, 2012 at 6:59 PM, Matt Newville <[email protected]> wrote:

Hi Pavel,

Since you mentioned pyepics and numpy, I'll jump in to recommend a
slightly different waveform -> Image conversion using these:

   import Image
   import epics

   waveform_pv = epics.PV('xx:waveform.VAL')
   waveform = waveform_pv.get()  # will be a numpy array of unsigned ints
   # to get a truncated waveform, pass in the length you'd like:
   #     waveform = waveform_pv.get(count=400)

   width = ??     # that is, you'll have to assert this here.
   height = len(waveform)/width

   image = Image.frombuffer('L', (width, height), waveform, 'raw', 'L', 0, 1)
   image.show()

where you'll have the know the image height and width somehow to
unravel the 1-d waveform.   The Image.frombuffer() call is slightly
cryptic, but documented ('L' means 8-bit greyscale -- if you're
waveform held RGB data from a color camera, you'd change that here to
get a color image), and is faster than converting to a string and then
using Image.open().

--Matt



--
Best regards,


Pavel Maslov, MS
Controls Engineer at Pulsed power Lab
Efremov Institute for Electro-Physical Apparatus
St. Petersburg, Russia

Mobile: +7 (951) 672 22 19
Landline: +7 (812) 461 01 01


Replies:
Re: [Scopes] BMP image record?? Rod Nussbaumer
Re: [Scopes] BMP image record?? Matt Newville
References:
[Scopes] BMP image record?? Pavel Masloff
RE: [Scopes] BMP image record?? Mark Rivers
Re: [Scopes] BMP image record?? Pavel Masloff
RE: [Scopes] BMP image record?? Mark Rivers
Re: [Scopes] BMP image record?? Pavel Masloff
RE: [Scopes] BMP image record?? Mark Rivers
Re: [Scopes] BMP image record?? Pavel Masloff
RE: [Scopes] BMP image record?? Wang Xiaoqiang
Re: [Scopes] BMP image record?? Pavel Masloff
Re: [Scopes] BMP image record?? Matt Newville

Navigate by Date:
Prev: Re: Fwd: Cosylab MicroIOC/BLM Calibration procedure confusion Uwe Bonnes
Next: Re: [Scopes] BMP image record?? Rod Nussbaumer
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: [Scopes] BMP image record?? Matt Newville
Next: Re: [Scopes] BMP image record?? Rod Nussbaumer
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·