Normalizing RGB coordinates in an image
Mostrar comentarios más antiguos
I've tried to make a program to separate and normalize the colors of an image, and made the following code.
The intention is to make a binary image from the green one. But all my color-normalized images appear entirely black.
Would someone please help me figure out whats wrong?
%separating colors:
grassimg=imread('grass.jpg');
colorimgR=grassimg(:,:,1);
colorimgG=grassimg(:,:,2);
colorimgB=grassimg(:,:,3);
%All these images appeares in different kind of greyscales.
%Thresholding the "green" image:
thresh_green = colorimgG >100;
figure(2)
rez_threshg = imresize(thresh_green, 0.5);
imshow(rez_threshg)
%I get a quite ok binary image.
%Normalizing colors (this is what turns out wrong):
allcolors = colorimgR+colorimgG+colorimgB;
redimg = colorimgR./allcolors;
greenimg = colorimgG./allcolors;
blueimg = colorimgB./allcolors;
figure(3)
subplot(1,3,1);
imshow(redimg)
subplot(1,3,2);
imshow(greenimg)
subplot(1,3,3);
imshow(blueimg)
%All these single-colored images turnes out black
%Obviously it does'nt work to binarize a black image... :
threshGimg = greenimg > 100;
figure(4)
rez_greenimg = imresize(greenimg, 0.5);
imshow(rez_greenimg)
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Modify Image Colors en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!