Cropping image to 8 bit

2 vues (au cours des 30 derniers jours)
dinda ayusma
dinda ayusma le 7 Jan 2021
Commenté : dinda ayusma le 12 Jan 2021
hai friends,,i want to ask about how to cropping the image to 256 x 256 piksel (8 bit) using matlab??? Thankyou before

Réponses (1)

Walter Roberson
Walter Roberson le 7 Jan 2021
im2uint8()
  11 commentaires
Walter Roberson
Walter Roberson le 12 Jan 2021
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 le 12 Jan 2021
why not detected variabel imbinarize?

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by