Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
save images after colormap('gray')

Subject: save images after colormap('gray')

From: MK

Date: 17 Jun, 2013 00:56:08

Message: 1 of 2

Hello,

please i have a code which detect skin

vid=VideoReader('nice-to-meet-you.wmv');
    for ii = 1:50
im = read(vid,ii);
    im = double(im);
    skinprob = computeSkinProbability(im); %computeSkin this another file.m
image((skinprob>0)*64);
       colormap('gray');
end


after this line colormap('gray'); it show me the skin detection which applied on video
what i need , i want to save images after colormap('gray');

Note : when i write it :
imwrite(image,fullfile(sprintf('img_%d.jpg',ii+1)));
it didn't show me anything ....

how can i do it please ?

Subject: save images after colormap('gray')

From: Steven_Lord

Date: 17 Jun, 2013 14:46:47

Message: 2 of 2



"MK " <mohamedebnzedan@yahoo.com> wrote in message
news:kplmr8$qcv$1@newscl01ah.mathworks.com...
> Hello,
>
> please i have a code which detect skin
>
> vid=VideoReader('nice-to-meet-you.wmv');
> for ii = 1:50
> im = read(vid,ii);
> im = double(im);
> skinprob = computeSkinProbability(im); %computeSkin this another file.m
> image((skinprob>0)*64);
> colormap('gray');
> end
>
>
> after this line colormap('gray'); it show me the skin detection which
> applied on video
> what i need , i want to save images after colormap('gray');

The COLORMAP command does NOT change the underlying data; all it does is
change how that data is displayed in that figure.

> Note : when i write it :
> imwrite(image,fullfile(sprintf('img_%d.jpg',ii+1)));
> it didn't show me anything ....

There are two problems. The first is that if you've defined a variable named
image, it overrides the IMAGE function; you will not be able to use the
IMAGE function while the variable exists. For that reason I'd use a
different variable name. If you haven't defined a variable named image, then
this tries to call the IMAGE function with one output and no input and write
that output to the file. That output will be a handle to the displayed
image, not the image data itself.

The second is that while you used the GRAY colormap in your figure, you
haven't told IMWRITE to use it. Use the syntax where the first two inputs to
IMWRITE are X and map to do this.

http://www.mathworks.com/help/matlab/ref/imwrite.html

Use the GRAY function on its own to generate the colormap to use as the map
input.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

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.

Contact us