I keep getting the error " Index exceeds matrix dimensions." How do I fix this?
조회 수: 4 (최근 30일)
이전 댓글 표시
%1
Self=imread('selfie.jpg');
P = rgb2gray(Self);
% figure
% subplot(1,2,1)
% %2
% imshow(P); title('Histogram Equalization')
% subplot(1,2,2)
% imhist(P,64)
% J = histeq(P);
% figure
% subplot(1,2,1)
% imshow(J); title('Enhanced Histogram Equalization')
% subplot(1,2,2)
% imhist(J,64)
% %3 Histogram Specification
%imgr=P(:,:,1);
imgg=P(:,:,2);
imgb=P(:,:,3);
imgr2=Self(:,:,1);
imgg2=Self(:,:,2);
imgb2=Self(:,:,3);*_
Hnimgr2= imhist(imgr2);
Hnimgg2= imhist(imgg2);
Hnimgb2= imhist(imgb2);*
outr=histeq(imgr,Hnimgr2);
outg=histeq(imgg,Hnimgg2);
outb=histeq(imgb,Hnimgb2);
histsp(:,:,1) = outr;
histsp(:,:,2) = outg;
histsp(:,:,3) = outb;
figure;
subplot(221);imshow(Self);title('Refrence Image');
subplot(222);imshow(P);title('Input Image');
subplot(224);imshow(histsp);title('Result Image');
Plot for Histogram Specification
figure;
subplot(331);plot(Hnimgr);title('Red Input');
subplot(334);plot(Hnimgg);title('Green Input');
subplot(337);plot(Hnimgb);title('Blue Input');
subplot(332);plot(Hnimgr2);title('Red Reference');
subplot(335);plot(Hnimgg2);title('Green Reference');
subplot(338);plot(Hnimgb2);title('Blue Reference');
subplot(333);plot(outr);title('Red Result');
subplot(336);plot(outg);title('Green Result');
subplot(339);plot(outb);title('Blue Result');
The error starts at line 19
댓글 수: 0
답변 (1개)
Walter Roberson
2018년 3월 21일
You did rgb2gray(). The result is, by definition, grayscale, which only has one color channel.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!