Thread Subject: imwrite

Subject: imwrite

From: Oluwa KuIse

Date: 9 Mar, 2009 17:25:03

Message: 1 of 5

Hello,
Can anyone please help me out with the imwrite function.
When I use it, it creates the file quite alright but it doesn't display the image. I have tried it with both the .png and .jpeg formats. Any suggestions?
Thank you all.
Oluwa KuIse

Subject: imwrite

From: Peter Boettcher

Date: 9 Mar, 2009 17:27:12

Message: 2 of 5

"Oluwa KuIse" <wespeakforex@yahoo.com> writes:

> Hello, Can anyone please help me out with the imwrite function. When
> I use it, it creates the file quite alright but it doesn't display the
> image. I have tried it with both the .png and .jpeg formats. Any
> suggestions?

What problem are you having? imwrite is supposed to create the file.
It is not supposed to display anything. Are you looking for image() or
imshow() instead? Or would you specifically like to do something with
the image file after it is written?

-Peter

Subject: imwrite

From: Oluwa KuIse

Date: 9 Mar, 2009 18:47:01

Message: 3 of 5

Peter Boettcher <boettcher@ll.mit.edu> wrote in message <muy63iili8f.fsf@G99-Boettcher.llan.ll.mit.edu>...
> "Oluwa KuIse" <wespeakforex@yahoo.com> writes:
>
> > Hello, Can anyone please help me out with the imwrite function. When
> > I use it, it creates the file quite alright but it doesn't display the
> > image. I have tried it with both the .png and .jpeg formats. Any
> > suggestions?
>
> What problem are you having? imwrite is supposed to create the file.
> It is not supposed to display anything. Are you looking for image() or
> imshow() instead? Or would you specifically like to do something with
> the image file after it is written?
>
> -Peter

Hi, Peter,
Thanks for your fast response. What I want to do is for MATLAB to be able to display my image in any file I want outside of MATLAB. The results (images) are to be displayed elsewhere and not on MATLAB's figure window. These are the last lines of the program:
source_color = im2uint8([.5 .5 1]);
E = im2uint8(mat2gray(E));
red = E;
green = E;
blue = E;
red(BW) = source_color(1);
green(BW) = source_color(2);
blue(BW) = source_color(3);
rgb_bottom = cat(3, red, green, blue);
imshow(rgb_bottom, 'InitialMag', 'fit')

% Make a second RGB image that is a constant green.
rgb_top = zeros(size(M,1), size(M,2), 3, 'uint8');
rgb_top(:,:,2) = 255;

% Turn the influence or dependence map into an AlphaData channel to be used
% to display with the green image.
M(BW) = 0;
M = imadjust(mat2gray(M), [0 1], [0 .6], 0.5);

image('CData', rgb_top, 'AlphaData', M);

Question: Image() displays the image in a MATLAB figure window. I want to be able to display this image in say, .jpeg.
Thank you!

Subject: imwrite

From: Peter Boettcher

Date: 9 Mar, 2009 19:15:15

Message: 4 of 5

"Oluwa KuIse" <wespeakforex@yahoo.com> writes:

> Peter Boettcher <boettcher@ll.mit.edu> wrote in message <muy63iili8f.fsf@G99-Boettcher.llan.ll.mit.edu>...
>> "Oluwa KuIse" <wespeakforex@yahoo.com> writes:
>>
>> > Hello, Can anyone please help me out with the imwrite function. When
>> > I use it, it creates the file quite alright but it doesn't display the
>> > image. I have tried it with both the .png and .jpeg formats. Any
>> > suggestions?
>>
>> What problem are you having? imwrite is supposed to create the file.
>> It is not supposed to display anything. Are you looking for image() or
>> imshow() instead? Or would you specifically like to do something with
>> the image file after it is written?
>>
>> -Peter
>
> Hi, Peter,
> Thanks for your fast response. What I want to do is for MATLAB to be able to display my image in any file I want outside of MATLAB. The results (images) are to be displayed elsewhere and not on MATLAB's figure window. These are the last lines of the program:
> source_color = im2uint8([.5 .5 1]);
> E = im2uint8(mat2gray(E));
> red = E;
> green = E;
> blue = E;
> red(BW) = source_color(1);
> green(BW) = source_color(2);
> blue(BW) = source_color(3);
> rgb_bottom = cat(3, red, green, blue);
> imshow(rgb_bottom, 'InitialMag', 'fit')
>
> % Make a second RGB image that is a constant green.
> rgb_top = zeros(size(M,1), size(M,2), 3, 'uint8');
> rgb_top(:,:,2) = 255;
>
> % Turn the influence or dependence map into an AlphaData channel to be used
> % to display with the green image.
> M(BW) = 0;
> M = imadjust(mat2gray(M), [0 1], [0 .6], 0.5);
>
> image('CData', rgb_top, 'AlphaData', M);
>
> Question: Image() displays the image in a MATLAB figure window. I want to be able to display this image in say, .jpeg.
> Thank you!

Ah. Use "saveas" or "print" to take a snapshot of your figure window
and export it to a file.



-Peter

Subject: imwrite

From: Adam

Date: 9 Mar, 2009 19:53:01

Message: 5 of 5

"Oluwa KuIse" <wespeakforex@yahoo.com> wrote in message <gp3o75$rr7$1@fred.mathworks.com>...

> Question: Image() displays the image in a MATLAB figure window. I want to be able to display this image in say, .jpeg.
> Thank you!

You probably need to scale your data. imwrite() clips everything outside the range [0, 1]

% compare these two
imwrite(magic(100), 'test.jpg')
imwrite(magic(100)/100^2, 'test2.jpg')

~Adam

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

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 Terms prior to use.

Contact us at files@mathworks.com