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.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
% 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
0 commentaires
Réponses (1)
Gayathri
le 7 Août 2024
Hi Boutrid,
This has been implemented in MATLAB R2024a version.I have used “peppers.png” image for solving the issue mentioned. I was not able to reproduce the result. Hence, please recheck the size of the image used, using size() function and then use the corresponding values in the reshape function. The code has been attached for reference
The output has been attached for reference for “pepper.png”.
0 commentaires
Voir également
Catégories
En savoir plus sur Matrox Hardware dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!