Filter löschen
Filter löschen

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 Ansichten (letzte 30 Tage)
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 Kommentare
Sumit Chaudhary
Sumit Chaudhary am 26 Apr. 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

KSSV
KSSV am 26 Apr. 2017
Bearbeitet: KSSV am 26 Apr. 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

Weitere Antworten (0)

Kategorien

Mehr zu Read, Write, and Modify Image finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by