Image1 = im2double(imread('image\test.png'));g=rgb2gray(Image1);b=imread('image\1.jpg');imshow(b);[row column page] = size(Image1)for i = rowfor j = columnif (Image1 (i, j, 2) > Image1(i, j, 1) && Image1(i, j, 2) > Image1(i, j, 3))Image2 (i, j, 1) = Image1 (i, j, 1);Image2 (i, j, 2) = Image1 (i, j, 2);Image2 (i, j, 3) = Image1 (i, j, 3);elseImage2 (i, j, 1) = 0;Image2 (i, j, 2) = 0;Image2 (i, j, 3) = 0;endendend[row column page] = size(Image1)for i = rowfor j = columnGreen = Image1 (i, j, 2) + 20;if (Green > Image1(i, j, 1) && Green > Image1(i, j, 3))Image2 (i, j, 1) = Image1 (i, j, 1);Image2 (i, j, 2) = Image1 (i, j, 2);Image2 (i, j, 3) = Image1 (i, j, 3);elseImage2 (i, j, 1) = 0;Image2 (i, j, 2) = 0;Image2 (i, j, 3) = 0;endendend[row column page] = size(Image2)imshow(Image2);
MATLAB: What is wrong with the following piece of code? Im trying to detect light and dark green vegetation. It just displays a black empty image
MATLAB
Related Question
- Cretae a video from Images using WriterObj
- How to convert the green pixels to white
- How can i solve median filter 5×5 on image on lena
- Decreasing range of values
- How to apply the arithmetic mean filter to a medical image to improve it? I have wrote this code but it did not work, there is an error which I could not figure it out.
- How to write a code to rearrage the colors in an RGB color array
Best Answer