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>.
2 ビュー (過去 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 件のコメント
採用された回答
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
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!