Effacer les filtres
Effacer les filtres

Why do i get an error when rgb image (tiff) is converted to grayscale ? The value of such image in workspcespace is like <556x663x4 uint8>. Rgb handles only images of type <556x663x3 uint8>.

6 vues (au cours des 30 derniers jours)
I am doing a project in which the grayscale value for a particular set of image is calculated. In an image(tiff format), there six sub images which are obtained by cropping the original image in microsoft office. After cropping during the processing of these six images, I face the issue of that some of the images not being read by matlab because of value of image is 556x663x4 uint8. The image being read are of the type 556x663x3 uint8. So, I want to know whether the issue is with cropping of tiff or with something else. THanks in advance.
  4 commentaires
Sumit Chaudhary
Sumit Chaudhary le 26 Avr 2017
Thanks for the suggestion. In the zip file, I have included the original image with six sub images and code for gray-scale value.

Connectez-vous pour commenter.

Réponse acceptée

KSSV
KSSV le 26 Avr 2017
Modifié(e) : KSSV le 26 Avr 2017
You can crop the image in MATLAB itself and do what you want. Check the below code.
I = imread('original.tif') ; % your original image
av = zeros(1,6) ;
for i = 1:6 % loop for each block
imshow(I) ;
[Image, rect] = imcrop(I); % select the image you want by dragging a rectangle
imwrite(Image,strcat(num2str(i),'.tif')) ; % save the cropped image
[pixelCount, grayLevels] = imhist(Image);
bar(grayLevels, pixelCount);
grid on;
av(i) = mean2(Image);
end

Plus de réponses (0)

Catégories

En savoir plus sur Read, Write, and Modify Image 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!

Translated by