Replace the white region in an binary image with Green ? and black colour unaffected
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Anand
am 28 Aug. 2014
Kommentiert: Anand
am 29 Aug. 2014
I Will read my input image as binary.(may be logical or uint8). The output must be Image with green colours in white region and black remains the same.
0 Kommentare
Akzeptierte Antwort
Joseph Cheng
am 28 Aug. 2014
Bearbeitet: Joseph Cheng
am 28 Aug. 2014
you can define the colormap used. here is a quick example
point3d = imread('pears.png');
value = rgb2gray(point3d);
BIN = value>124;
cmap = [ 0 0 0;0 1 0];
imagesc(BIN),colormap(cmap)
so since i have a binary i know the green area is the logical 1 and black 0. if it is not logical then you'll have to scale the colormap to the values of white and black.
2 Kommentare
Weitere Antworten (1)
Image Analyst
am 28 Aug. 2014
Anand, if you want an RGB image instead of a pseudocolored logical image (with values of 0 and 1) then you need to do this:
grayImage = uint8(255 * BIN); % BIN is from Joseph's code.
blackImage = zeros(size(grayImage), 'uint8');
rgbImage = cat(3, blackImage , grayImage, blackImage); % Only green channel is non-zero.
imshow(rgbImage);
imwrite(rgbImage, fullFileName);
Siehe auch
Kategorien
Mehr zu Red finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!