I have a picture in GIF-format which I need to process and
convert to eps. Using "imread", MATLAB reads the file into
a matrix with too few rows and columns. It seems that the
information about the file dimension is in another unit.
Can I control this? Looking through the helpfile I find
references to commands like "readimage" but no
documentation.
Robert Johansson wrote:
> I have a picture in GIF-format which I need to process and
> convert to eps. Using "imread", MATLAB reads the file into
> a matrix with too few rows and columns.
How do you know the matrix has too few rows and columns?
What does imfinfo say about the file?
> It seems that the
> information about the file dimension is in another unit.
What do you mean by "another unit"?
> Can I control this? Looking through the helpfile I find
> references to commands like "readimage" but no
> documentation.
I don't see any mention of "readimage" in the M-file help or reference
page for imread.
"Robert Johansson" <robert.nospam@math.umu.se> wrote in
message <fvl2ih$khs$1@fred.mathworks.com>...
> I have a picture in GIF-format which I need to process and
> convert to eps. Using "imread", MATLAB reads the file into
> a matrix with too few rows and columns. It seems that the
> information about the file dimension is in another unit.
> Can I control this? Looking through the helpfile I find
> references to commands like "readimage" but no
> documentation.
Hi,
better to use importdata, cause gif will be saved like a
structure, here is a small example:
"Robert Johansson" <robert.nospam@math.umu.se> wrote in
message <fvl2ih$khs$1@fred.mathworks.com>...
> I have a picture in GIF-format which I need to process and
> convert to eps. Using "imread", MATLAB reads the file into
> a matrix with too few rows and columns. It seems that the
> information about the file dimension is in another unit.
> Can I control this? Looking through the helpfile I find
> references to commands like "readimage" but no
> documentation.
Hi,
better to use importdata, cause gif will be saved like a
structure, here is a small example:
The matrix that I get from imread (and importdata) is of
size 87x87, that is not even close to what is needed to get
a correct version of the picture. I know what the picture
should look like. This is the file info:
If I examine the file properties by right-clicking on it,
the system tells me that the size is given in "points"
(87x87). Its a picture of a logo which i want to use in
LaTeX so my idea was to convert it to eps with MATLAB.
/Robert
Steve Eddins <Steve.Eddins@mathworks.com> wrote in message
<fvn2qd$rpv$1@fred.mathworks.com>...
> Robert Johansson wrote:
> > I have a picture in GIF-format which I need to process
and
> > convert to eps. Using "imread", MATLAB reads the file
into
> > a matrix with too few rows and columns.
>
> How do you know the matrix has too few rows and columns?
>
> What does imfinfo say about the file?
>
> > It seems that the
> > information about the file dimension is in another unit.
>
> What do you mean by "another unit"?
>
> > Can I control this? Looking through the helpfile I find
> > references to commands like "readimage" but no
> > documentation.
>
> I don't see any mention of "readimage" in the M-file help
or reference
> page for imread.
>
> What do you get when you type this at prompt:
>
> which -all imread
>
>
> ---
> Steve Eddins
> http://blogs.mathworks.com/steve/
>
Robert Johansson wrote:
> The matrix that I get from imread (and importdata) is of
> size 87x87, that is not even close to what is needed to get
> a correct version of the picture. I know what the picture
> should look like. This is the file info:
>
> FileSize: 3464
> Format: 'GIF'
> FormatVersion: '89a'
> Width: 87
> Height: 87
> BitDepth: 8
> ColorType: 'indexed'
> FormatSignature: 'GIF89a'
> BackgroundColor: 0
> AspectRatio: 0
> ColorTable: [256x3 double]
> Interlaced: 'no'
>
> If I examine the file properties by right-clicking on it,
> the system tells me that the size is given in "points"
> (87x87). Its a picture of a logo which i want to use in
> LaTeX so my idea was to convert it to eps with MATLAB.
>
> /Robert
Sounds to me like you have a GIF file containing 87 rows and 87 pixels,
and this is what imread is giving you. It also sounds to me like the
Windows file properties dialog is confirming this for you.
Try reading the image file using some other application if you still
have doubts.
Where is your notion of "correct version of the picture" coming from?
The one to the left is of size 101x101 but a matrix of
101x101 is not enough to describe it. I guess that it has
something to do with to file format.
/Robert
Steve Eddins <Steve.Eddins@mathworks.com> wrote in message
<fvpn6m$rt6$1@fred.mathworks.com>...
> Robert Johansson wrote:
> > The matrix that I get from imread (and importdata) is
of
> > size 87x87, that is not even close to what is needed to
get
> > a correct version of the picture. I know what the
picture
> > should look like. This is the file info:
> >
> > FileSize: 3464
> > Format: 'GIF'
> > FormatVersion: '89a'
> > Width: 87
> > Height: 87
> > BitDepth: 8
> > ColorType: 'indexed'
> > FormatSignature: 'GIF89a'
> > BackgroundColor: 0
> > AspectRatio: 0
> > ColorTable: [256x3 double]
> > Interlaced: 'no'
> >
> > If I examine the file properties by right-clicking on
it,
> > the system tells me that the size is given in "points"
> > (87x87). Its a picture of a logo which i want to use in
> > LaTeX so my idea was to convert it to eps with MATLAB.
> >
> > /Robert
>
> Sounds to me like you have a GIF file containing 87 rows
and 87 pixels,
> and this is what imread is giving you. It also sounds to
me like the
> Windows file properties dialog is confirming this for you.
>
> Try reading the image file using some other application
if you still
> have doubts.
>
> Where is your notion of "correct version of the picture"
coming from?
>
> Steve
> Steve Eddins <Steve.Eddins@mathworks.com> wrote in message
> <fvpn6m$rt6$1@fred.mathworks.com>...
>> Robert Johansson wrote:
>> > The matrix that I get from imread (and importdata) is of size
>> > 87x87, that is not even close to what is needed to get a correct
>> > version of the picture. I know what the picture should look
>> > like. This is the file info:
>> >
>> > FileSize: 3464
>> > Format: 'GIF'
>> > FormatVersion: '89a'
>> > Width: 87
>> > Height: 87
>> > BitDepth: 8
>> > ColorType: 'indexed'
>> > FormatSignature: 'GIF89a'
>> > BackgroundColor: 0
>> > AspectRatio: 0
>> > ColorTable: [256x3 double]
>> > Interlaced: 'no'
>> >
>> > If I examine the file properties by right-clicking on it, the
>> > system tells me that the size is given in "points" (87x87). Its a
>> > picture of a logo which i want to use in LaTeX so my idea was to
>> > convert it to eps with MATLAB.
>> Sounds to me like you have a GIF file containing 87 rows and 87
>> pixels, and this is what imread is giving you. It also sounds to me
>> like the Windows file properties dialog is confirming this for you.
>>
>> Try reading the image file using some other application if you still
>> have doubts.
>>
>> Where is your notion of "correct version of the picture" coming from?
>
>
> Its a logotype.
>
> http://www.umu.se/umu/profil/allmant/logotyp.html
>
> The one to the left is of size 101x101 but a matrix of
> 101x101 is not enough to describe it. I guess that it has
> something to do with to file format.
What? You really need to explain what you mean by "not enough to
describe it", or "not even close to what is needed to get a correct
version of". Everything seems entirely consistent. The image has size
101x101 pixels. It is displayed at exactly that size on the web.
Windows "properties" says it is 101x101 pixels. When you read it into
MATLAB you get a matrix of 101x101 pixels.
And when I display the 101x101 matrix in MATLAB, it looks exactly like
the web.
Maybe the code you use to display the image is wrong? Here's what I
did:
Peter Boettcher <boettcher@ll.mit.edu> wrote in message
<muy4p9bibud.fsf@G99-Boettcher.llan.ll.mit.edu>...
>
> [correcting top-post]
>
> "Robert Johansson" <robert.nospam@math.umu.se> writes:
>
> > Steve Eddins <Steve.Eddins@mathworks.com> wrote in
message
> > <fvpn6m$rt6$1@fred.mathworks.com>...
> >> Robert Johansson wrote:
> >> > The matrix that I get from imread (and importdata)
is of size
> >> > 87x87, that is not even close to what is needed to
get a correct
> >> > version of the picture. I know what the picture
should look
> >> > like. This is the file info:
> >> >
> >> > FileSize: 3464
> >> > Format: 'GIF'
> >> > FormatVersion: '89a'
> >> > Width: 87
> >> > Height: 87
> >> > BitDepth: 8
> >> > ColorType: 'indexed'
> >> > FormatSignature: 'GIF89a'
> >> > BackgroundColor: 0
> >> > AspectRatio: 0
> >> > ColorTable: [256x3 double]
> >> > Interlaced: 'no'
> >> >
> >> > If I examine the file properties by right-clicking
on it, the
> >> > system tells me that the size is given in "points"
(87x87). Its a
> >> > picture of a logo which i want to use in LaTeX so my
idea was to
> >> > convert it to eps with MATLAB.
>
> >> Sounds to me like you have a GIF file containing 87
rows and 87
> >> pixels, and this is what imread is giving you. It
also sounds to me
> >> like the Windows file properties dialog is confirming
this for you.
> >>
> >> Try reading the image file using some other
application if you still
> >> have doubts.
> >>
> >> Where is your notion of "correct version of the
picture" coming from?
> >
> >
> > Its a logotype.
> >
> > http://www.umu.se/umu/profil/allmant/logotyp.html
> >
> > The one to the left is of size 101x101 but a matrix of
> > 101x101 is not enough to describe it. I guess that it
has
> > something to do with to file format.
>
> What? You really need to explain what you mean by "not
enough to
> describe it", or "not even close to what is needed to get
a correct
> version of". Everything seems entirely consistent. The
image has size
> 101x101 pixels. It is displayed at exactly that size on
the web.
> Windows "properties" says it is 101x101 pixels. When you
read it into
> MATLAB you get a matrix of 101x101 pixels.
>
> And when I display the 101x101 matrix in MATLAB, it looks
exactly like
> the web.
>
> Maybe the code you use to display the image is wrong?
Here's what I
> did:
>
> [s map] = imread('UMU_pos.gif');
> image(s);
> colormap(map);
> truesize;
>
>
>
> -Peter
I'm sorry if my explanation was poor. If I do the
conversion to eps with my own code, or with your code, I
get a new picture of poor quality. I scaled the eps with
LaTeX to exactly the same size as the original (20mm) and
put them side by side to be sure. There is no doubt that
something has been lost or distorted. Maybe this is a
problem with conversion from gif to eps that can't be
avoided with this method? I was just surprised that I didnt
get the same result when I read the gif-file and converted
it with MATLAB.
>> What? You really need to explain what you mean by "not enough to
>> describe it", or "not even close to what is needed to get a correct
>> version of". Everything seems entirely consistent. The image has
>> size 101x101 pixels. It is displayed at exactly that size on the
>> web. Windows "properties" says it is 101x101 pixels. When you read
>> it into MATLAB you get a matrix of 101x101 pixels.
>>
>> And when I display the 101x101 matrix in MATLAB, it looks exactly
>> like the web.
>>
>> Maybe the code you use to display the image is wrong? Here's what I
>> did:
>>
>> [s map] = imread('UMU_pos.gif');
>> image(s);
>> colormap(map);
>> truesize;
>>
>>
>>
>> -Peter
>
> I'm sorry if my explanation was poor. If I do the conversion to eps
> with my own code, or with your code, I get a new picture of poor
> quality. I scaled the eps with LaTeX to exactly the same size as the
> original (20mm) and put them side by side to be sure. There is no
> doubt that something has been lost or distorted. Maybe this is a
> problem with conversion from gif to eps that can't be avoided with
> this method? I was just surprised that I didnt get the same result
> when I read the gif-file and converted it with MATLAB.
OK, that's a different issue. Raster formats in EPS can be... tricky.
What code are you using to generate the EPS file? And how are you
comparing the output results to the GIF version?
Peter Boettcher <boettcher@ll.mit.edu> wrote in message
<muyzlr3gsuu.fsf@G99-Boettcher.llan.ll.mit.edu>...
> "Robert Johansson" <robert.nospam@math.umu.se> writes:
>
> >> What? You really need to explain what you mean
by "not enough to
> >> describe it", or "not even close to what is needed to
get a correct
> >> version of". Everything seems entirely consistent.
The image has
> >> size 101x101 pixels. It is displayed at exactly that
size on the
> >> web. Windows "properties" says it is 101x101 pixels.
When you read
> >> it into MATLAB you get a matrix of 101x101 pixels.
> >>
> >> And when I display the 101x101 matrix in MATLAB, it
looks exactly
> >> like the web.
> >>
> >> Maybe the code you use to display the image is wrong?
Here's what I
> >> did:
> >>
> >> [s map] = imread('UMU_pos.gif');
> >> image(s);
> >> colormap(map);
> >> truesize;
> >>
> >>
> >>
> >> -Peter
> >
> > I'm sorry if my explanation was poor. If I do the
conversion to eps
> > with my own code, or with your code, I get a new
picture of poor
> > quality. I scaled the eps with LaTeX to exactly the
same size as the
> > original (20mm) and put them side by side to be sure.
There is no
> > doubt that something has been lost or distorted. Maybe
this is a
> > problem with conversion from gif to eps that can't be
avoided with
> > this method? I was just surprised that I didnt get the
same result
> > when I read the gif-file and converted it with MATLAB.
>
> OK, that's a different issue. Raster formats in EPS can
be... tricky.
> What code are you using to generate the EPS file? And
how are you
> comparing the output results to the GIF version?
>
> -Peter
Thanks, thats nice to know. I have tried many different
approaces. The most promising is this one
but it doesn't work properly. I realize that 20 mm is
probably wrong size. I got it from the webbpage where I
found the gif. I thouth it should be right if I ran my
function with storlek=101 ... but its not right.
> Peter Boettcher <boettcher@ll.mit.edu> wrote in message
> <muyzlr3gsuu.fsf@G99-Boettcher.llan.ll.mit.edu>...
>> OK, that's a different issue. Raster formats in EPS can
>> be... tricky. What code are you using to generate the EPS file? And
>> how are you comparing the output results to the GIF version?
>>
>> -Peter
>
> Thanks, thats nice to know. I have tried many different
> approaces. The most promising is this one
>
> function logo(storlek)
>
> [s map] = imread('UMU_pos.gif');
> image(s);
> colormap(map);
> set(gcf,'units','points','position',[0 0 storlek
> storlek],'color',[0 0 0])
> axes('units','points','position',[0 0 storlek
> storlek],'visible','off')
>
> end
>
> but it doesn't work properly. I realize that 20 mm is
> probably wrong size. I got it from the webbpage where I
> found the gif. I thouth it should be right if I ran my
> function with storlek=101 ... but its not right.
'points' do not mean 'pixels'. 'points' are related to font sizes. You
want pixels.
The 'axes' call creates a new axis. Instead you want to
set(gca, 'units', 'pixels', [0 0 101 101]);
"axis off" is the right way to turn off the hash marks.
I also do not see any code that exports to an EPS. Printing uses some
other values that you need to get right. 'PaperPosition', the -r value
in the print command to specify printing resolution, etc.
Robert Johansson wrote:
> Its a logotype.
>
> http://www.umu.se/umu/profil/allmant/logotyp.html
>
> The one to the left is of size 101x101 but a matrix of
> 101x101 is not enough to describe it. I guess that it has
> something to do with to file format.
If you have an image with 101 rows and 101 columns of pixels, then a
101x101 matrix is just what you need to describe it exactly. File
format has nothing to do with it.
Peter Boettcher <boettcher@ll.mit.edu> wrote in message
<muyr6cfgo6x.fsf@G99-Boettcher.llan.ll.mit.edu>...
> "Robert Johansson" <robert.nospam@math.umu.se> writes:
>
> > Peter Boettcher <boettcher@ll.mit.edu> wrote in message
> > <muyzlr3gsuu.fsf@G99-Boettcher.llan.ll.mit.edu>...
>
> >> OK, that's a different issue. Raster formats in EPS
can
> >> be... tricky. What code are you using to generate the
EPS file? And
> >> how are you comparing the output results to the GIF
version?
> >>
> >> -Peter
> >
> > Thanks, thats nice to know. I have tried many different
> > approaces. The most promising is this one
> >
> > function logo(storlek)
> >
> > [s map] = imread('UMU_pos.gif');
> > image(s);
> > colormap(map);
> > set(gcf,'units','points','position',[0 0 storlek
> > storlek],'color',[0 0 0])
> > axes('units','points','position',[0 0 storlek
> > storlek],'visible','off')
> >
> > end
> >
> > but it doesn't work properly. I realize that 20 mm is
> > probably wrong size. I got it from the webbpage where I
> > found the gif. I thouth it should be right if I ran my
> > function with storlek=101 ... but its not right.
>
> 'points' do not mean 'pixels'. 'points' are related to
font sizes. You
> want pixels.
>
> The 'axes' call creates a new axis. Instead you want to
> set(gca, 'units', 'pixels', [0 0 101 101]);
>
> "axis off" is the right way to turn off the hash marks.
>
> I also do not see any code that exports to an EPS.
Printing uses some
> other values that you need to get
right. 'PaperPosition', the -r value
> in the print command to specify printing resolution, etc.
>
> -Peter
Thanks! I looks fine now. I saved to eps from the figure
menu instead of printing directly from the m-file.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.