I want to segment an apple fruit image and i’m using histogram’s method but when i’m using the function: n=hist(reshape(double(rgb(:,:,i)),[480*640 1]),0.5:256); i have this error: To RESHAPE the number of elements must not change.
% load image (colorful fabric acquired with frame grabber and camera)
rgb = imread(‘7.png’); % Matrox frame grabber + Pulnix camera
imshow(rgb)
% explore color content using image viewer
imshow(rgb)
% smooth image (reduce noise/color variation)
rgb = imfilter(rgb,ones(3,3)/9);
imshow(rgb)
% view image and RGB layers (nonuniform illumination)
figure(1), set(1,’position’,[99 79 826 589])
subplot(2,2,1), subimage(rgb), title(‘fabric image’), axis off
subplot(2,2,2), map=gray(256); map(:,2:3)=0; subimage(rgb(:,:,1),map), title(‘red layer’), axis off
subplot(2,2,3), map=gray(256); map(:,[1 3])=0; subimage(rgb(:,:,2),map), title(‘green layer’), axis off
subplot(2,2,4), map=gray(256); map(:,1:2)=0; subimage(rgb(:,:,3),map), title(‘blue layer’), axis off
% RGB histograms (poor separability)
figure(1), set(1,’position’,[452 68 560 420])
figure(2), set(2,’position’,[16 269 560 420])
c=’rgb’;
for i=1:3
n=hist(reshape(double(rgb(:,:,i)),[480*640 1]),0.5:256);
line(0:255,n,’color’,c(i))
end% load image (colorful fabric acquired with frame grabber and camera)
rgb = imread(‘7.png’); % Matrox frame grabber + Pulnix camera
imshow(rgb)
% explore color content using image viewer
imshow(rgb)
% smooth image (reduce noise/color variation)
rgb = imfilter(rgb,ones(3,3)/9);
imshow(rgb)
% view image and RGB layers (nonuniform illumination)
figure(1), set(1,’position’,[99 79 826 589])
subplot(2,2,1), subimage(rgb), title(‘fabric image’), axis off
subplot(2,2,2), map=gray(256); map(:,2:3)=0; subimage(rgb(:,:,1),map), title(‘red layer’), axis off
subplot(2,2,3), map=gray(256); map(:,[1 3])=0; subimage(rgb(:,:,2),map), title(‘green layer’), axis off
subplot(2,2,4), map=gray(256); map(:,1:2)=0; subimage(rgb(:,:,3),map), title(‘blue layer’), axis off
% RGB histograms (poor separability)
figure(1), set(1,’position’,[452 68 560 420])
figure(2), set(2,’position’,[16 269 560 420])
c=’rgb’;
for i=1:3
n=hist(reshape(double(rgb(:,:,i)),[480*640 1]),0.5:256);
line(0:255,n,’color’,c(i))
end % load image (colorful fabric acquired with frame grabber and camera)
rgb = imread(‘7.png’); % Matrox frame grabber + Pulnix camera
imshow(rgb)
% explore color content using image viewer
imshow(rgb)
% smooth image (reduce noise/color variation)
rgb = imfilter(rgb,ones(3,3)/9);
imshow(rgb)
% view image and RGB layers (nonuniform illumination)
figure(1), set(1,’position’,[99 79 826 589])
subplot(2,2,1), subimage(rgb), title(‘fabric image’), axis off
subplot(2,2,2), map=gray(256); map(:,2:3)=0; subimage(rgb(:,:,1),map), title(‘red layer’), axis off
subplot(2,2,3), map=gray(256); map(:,[1 3])=0; subimage(rgb(:,:,2),map), title(‘green layer’), axis off
subplot(2,2,4), map=gray(256); map(:,1:2)=0; subimage(rgb(:,:,3),map), title(‘blue layer’), axis off
% RGB histograms (poor separability)
figure(1), set(1,’position’,[452 68 560 420])
figure(2), set(2,’position’,[16 269 560 420])
c=’rgb’;
for i=1:3
n=hist(reshape(double(rgb(:,:,i)),[480*640 1]),0.5:256);
line(0:255,n,’color’,c(i))
end color image segmentation for apple fruit MATLAB Answers — New Questions