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 次查看(过去 30 天)
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 个评论
Sumit Chaudhary
Sumit Chaudhary 2017-4-26
Thanks for the suggestion. In the zip file, I have included the original image with six sub images and code for gray-scale value.

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2017-4-26
编辑:KSSV 2017-4-26
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Read, Write, and Modify Image 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by