How have I separate only one color?
13 views (last 30 days)
Show older comments
Hi,
I have an image in RGB.
fragment of code:
clc,clear all,close all, format long g, format compact
A=imread('car.jpg');
a=size(A);
w_image=a(2);
h_image=a(1);
s=round(0.05*w_image);
w=round(0.05*h_image);
C=imcrop(A,[0.05*w_image 0.4*h_image ...
w_image-1.5*s h_image-w]);
figure(1),imshow(C)
red=C(:,:,1);
green=C(:,:,2);
blue=C(:,:,3);
How could I separate only one color from an image?
I want to display new image which shows all blue pixels from old one (other pixels should be black/white).
0 Comments
Answers (1)
Image Analyst
on 30 Jan 2013
You already separated it. And you know how to display.
imshow(blue);
I'm not sure how to interpret your last sentence. It doesn't make sense. The blue channel of a color image is a monochrome image. If you just display the values, you can use the normal gray colormap, or any other one you want. ANd what are "other pixels"? And what color are they now?
2 Comments
Image Analyst
on 30 Jan 2013
For better, more flexible and robust color segmentation, see my File Exchange where I have several methods.
See Also
Categories
Find more on Display Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!