g = visa('agilent', 'GPIB3::8::INSTR');
fopen(g)
f = zeros(480,640,'uint8');
fprintf(g,'DISP:DATA? GIF')
f = fread(g,[480,640],'uint8');
I have previously tried
%f = binblockread(g,'uint8');
with similar results, except that the length of the 1D
array changes slighty.
I also seem to be getting this warning associated with the
fread call.
"Warning: The EOI line was asserted before SIZE values were
available."
This occures with g.EOImode on and off.
>g = visa('agilent', 'GPIB3::8::INSTR');
>fopen(g)
>f = zeros(480,640,'uint8');
That setting of f should not have any effect; it could be deleted.
>fprintf(g,'DISP:DATA? GIF')
>f = fread(g,[480,640],'uint8');
Try '*uint8' instead of 'uint8'
--
"Tired minds don't plan well. Sleep first, plan later."
-- Walter Reisch
"Invalid PRECISION specified. Type 'instrhelp fread' for
more information."
My understanding is that this would be how you would do it
(as a substitute for 'uint8=>uint8' but the instr fread
wont allow this.
Literature:
http://www.mathworks.com/access/helpdesk/help/toolbox/instru
ment/index.html?/access/helpdesk/help/toolbox/instrument/fre
ad.html
Thanks though, any other ideas?
>> g = visa('agilent', 'GPIB3::8::INSTR');
>> fopen(g)
>> f = zeros(480,640,'uint8');
>> fprintf(g,'DISP:DATA? GIF')
>> f = fread(g,[480,640],'uint8');
The GIF in the string suggests that the output format that the device
is to create is to be GIF file format rather than just a block of
pixel values. GIF file format has a header, and data in GIF files
is compressed with a lossless compression algorithm. It would be
typical for a GIF file to be noticeably shorter than a dump of the
raw pixels it represents.
I am not familiar with data aquisition, but it appears to me that
you should request to read until end of file (or error), take
the resulting bytes and write them directly into a temporary file,
and then request to imread() that temporary file.
--
"I buy more from my grocer than he buys from me, and I bet it's
the same with you and your grocer. That means we have a trade
deficit with our grocers. Does our perpetual grocer trade deficit
portend doom?" -- Walter Williams
It is exactly that issue, that I am having. I thought
binblockread would be the solution, but the issue is that I
think I am reading 64 bits as one pixel value, instead of 8
bits. I am trying to read this data back and save it as a
image file, JPG, GIF, BMP, the format doesn't matter too
much.
I obviously need to figure out two things:
1) How to read 1 byte values instead of 8 byte values
2) How to split this up into a 2D array rather than a 1D
array.
I really want "f = fread(g,[480,640],'uint8');" to work as
a solution to these two problems. Anyone have any
suggestions? Again, my query is fprintf(g,'DISP:DATA?
[Anything]') Where [Anything] can be JPG, BMP, GIF etc. My
thinking is that BMP is the best option due to colors and
not having to have the 3D array that jpg requires.
Kyle
Hi Kyle
The binblockread should get the correct information even with the default
(uchar) options. Write the output to a file and try imread. The gif
compression may have sent you for a loop. You should not need to
shape/reshape the data.
If you don't use binblock, you will need to remove the header yourself.
This is the ~7 byte difference you notice.
Update: I have been able to get something from it using the
BMP setting.
g = visa('agilent', 'GPIB3::8::INSTR'); %set variable to
instrument
g.inputbuffersize = 1000000;
fopen(g);
fprintf(g,'DISP:DATA? BMP');
f = fread(g,[480,640],'uint8');
imwrite(f,'test.bmp','bmp')
It seems to be not only a small portion of the screen, but
with several components overlapping themselves. Thoughts?
>I really want "f = fread(g,[480,640],'uint8');" to work as
>a solution to these two problems. Anyone have any
>suggestions? Again, my query is fprintf(g,'DISP:DATA?
>[Anything]') Where [Anything] can be JPG, BMP, GIF etc. My
>thinking is that BMP is the best option due to colors and
>not having to have the 3D array that jpg requires.
Unless one of your options is RAW then you are going to be
disappointed in your want to read the data using that command.
JPG, BMP, GIF and all other file formats except RAW *all*
have headers on them, so even if there were no data compression
of any sort, the data to be read in would not be of length
480 * 640 . All of those formats are going to send you encapsulated
(and possibly compressed) data that you will pretty much need
to write to a file and imread() the data out of the file if you
want to process the data.
--
"Pray do not take the pains / To set me right. /
In vain my faults ye quote; / I wrote as others wrote /
On Sunium's hight." -- Walter Savage Landor
using binblockread simply outputs a 1D array that when I
imwrite it, a single horizontal line is produced. Upon
using the command imread, I simply get binary values (aka,
255 or 0). Perhaps there is a sample program around here
somewhere? I can't seem to find one.
>using binblockread simply outputs a 1D array that when I
>imwrite it, a single horizontal line is produced.
Don't imwrite() that data: fwrite() that data, and imread()
the result.
--
"Let me live in my house by the side of the road --
It's here the race of men go by.
They are good, they are bad, they are weak, they are strong
Wise, foolish -- so am I;" -- Sam Walter Foss
I'm begining to doubt my matlab skills. =(
If I fwrite the data, doesn't this presuppose a fid? If so,
(assuming I choose 1), how do I go about typing in the
filename for imread? Using a fid here doesn't work.
Don't chose an arbitrary fid.
fid = fopen(filename,'wb');
fwrite(fid,thedatabuffer,'*uint8');
fclose(fid);
--
"Do diddle di do,
Poor Jim Jay
Got stuck fast
In Yesterday." -- Walter De La Mare
Ok, got it. Thanks! Here's what I did incase anyone needs
it in the future.
fprintf(g,'DISP:DATA? BMP');
f = binblockread(g);
fid = fopen('test.bmp','w');
fwrite(fid,f,'uint8');
screen = imread('test.bmp','bmp');
image(screen)
You should fclose(fid) at this point.
>screen = imread('test.bmp','bmp');
>image(screen)
--
"I feel sorry for the person who can't get genuinely excited
about his work. Not only will he never be satisfied, but he will
never achieve anything worthwhile." -- Walter Chrysler