Effacer les filtres
Effacer les filtres

I want to display RGB channels separately and I wrote below code and executed it. Why it shows an error like "Index exceeds matrix dimensions. Error in clusteredit (line 21) green = imIDX(:,:,2); % Green channel" . Please tell me how to tackle this

1 vue (au cours des 30 derniers jours)
clear all;
newImageRGB = imread('p2_left_norm_1.bmp');
figure;
imshow(newImageRGB);
title('Original image');
grayImage = rgb2gray(newImageRGB);
figure;
imshow(grayImage);
title('grayscale image');
afterWiener = wiener2(grayImage,[6 6]);
figure;
imshow(afterWiener);
title('Wiener filter');
imData=reshape(afterWiener,[],1);
imData=im2double(imData);
[IDX mn]=kmeans(imData,3);
imIDX=reshape(IDX,size(afterWiener));
red = imIDX(:,:,1); % Red channel
green = imIDX(:,:,2); % Green channel
blue = imIDX(:,:,3); % Blue channel
a = zeros(size(imIDX, 1), size(imIDX, 2));
just_red = cat(3, red, a, a);
just_green = cat(3, a, green, a);
just_blue = cat(3, a, a, blue);
back_to_original_img = cat(3, red, green, blue);
figure, imshow(just_red), title('Red channel')
figure, imshow(just_green), title('Green channel')
figure, imshow(just_blue), title('Blue channel')

Réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by