Cropping image to 8 bit

조회 수: 2 (최근 30일)
dinda ayusma
dinda ayusma 2021년 1월 7일
댓글: dinda ayusma 2021년 1월 12일
hai friends,,i want to ask about how to cropping the image to 256 x 256 piksel (8 bit) using matlab??? Thankyou before

답변 (1개)

Walter Roberson
Walter Roberson 2021년 1월 7일
im2uint8()
  댓글 수: 11
Walter Roberson
Walter Roberson 2021년 1월 12일
im = imread('rice.png');
if ndims(im) < 3; im = repmat(im, 1, 1, 3); end
subplot(2,2,1)
imshow(im)
title('original')
im2 = imbinarize(rgb2gray(im));
im2 = bwareafilt(im2, 10);
props = regionprops(im2, 'boundingbox');
oneBB = props(1).BoundingBox;
imcrp = imcrop(im, oneBB);
subplot(2,2,2)
imshow(imcrp)
title('cropped')
im8 = im2uint8(imcrp);
subplot(2,2,3)
imshow(im8)
title('8 bit')
if isa(imcrp, 'uint8')
fprintf('Input image was ALREADY uint8\n');
else
fprintf('Input image was class %s, now converted to uint8\n', class(imcrp));
end
Input image was ALREADY uint8
d8 = double(im8);
img8p = uint8(cat(3, floor(d8(:,:,1)/64)*64, floor(d8(:,:,2)/32)*32, floor(d8(:,:,3)/64)*64));
subplot(2,2,4)
imshow(img8p)
title('pixelized to 8 bits')
dinda ayusma
dinda ayusma 2021년 1월 12일
why not detected variabel imbinarize?

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by