how to crop image automatically to 512x512px?
Hello everyone. I want to crop with the size of 512x512px. But matlab only save the image as 10×9 uint8. and also, I want it to crop at the center of the lesion without any specific area. can the matlab do such that task? here’s my code given below and result of the image that not at the center of the lesion.
close all;
I=imread(‘1_245.jpg’);
figure, imshow(I);
I=rgb2gray(I);
BW=I>100;
figure,imshow(BW);
labeledImage = bwlabel(BW);
measurements = regionprops(labeledImage, ‘BoundingBox’, ‘Area’);
for k = 1 : length(measurements)
thisBB = measurements(k).BoundingBox;
I2=imcrop(I,[thisBB(1),thisBB(2),thisBB(3),thisBB(4)]);
[rows, cols, depth]=size(I2);
if rows*cols>100
I2=imresize(I2,[512 512]);
figure,imshow(I2);
end
endHello everyone. I want to crop with the size of 512x512px. But matlab only save the image as 10×9 uint8. and also, I want it to crop at the center of the lesion without any specific area. can the matlab do such that task? here’s my code given below and result of the image that not at the center of the lesion.
close all;
I=imread(‘1_245.jpg’);
figure, imshow(I);
I=rgb2gray(I);
BW=I>100;
figure,imshow(BW);
labeledImage = bwlabel(BW);
measurements = regionprops(labeledImage, ‘BoundingBox’, ‘Area’);
for k = 1 : length(measurements)
thisBB = measurements(k).BoundingBox;
I2=imcrop(I,[thisBB(1),thisBB(2),thisBB(3),thisBB(4)]);
[rows, cols, depth]=size(I2);
if rows*cols>100
I2=imresize(I2,[512 512]);
figure,imshow(I2);
end
end Hello everyone. I want to crop with the size of 512x512px. But matlab only save the image as 10×9 uint8. and also, I want it to crop at the center of the lesion without any specific area. can the matlab do such that task? here’s my code given below and result of the image that not at the center of the lesion.
close all;
I=imread(‘1_245.jpg’);
figure, imshow(I);
I=rgb2gray(I);
BW=I>100;
figure,imshow(BW);
labeledImage = bwlabel(BW);
measurements = regionprops(labeledImage, ‘BoundingBox’, ‘Area’);
for k = 1 : length(measurements)
thisBB = measurements(k).BoundingBox;
I2=imcrop(I,[thisBB(1),thisBB(2),thisBB(3),thisBB(4)]);
[rows, cols, depth]=size(I2);
if rows*cols>100
I2=imresize(I2,[512 512]);
figure,imshow(I2);
end
end auto crop MATLAB Answers — New Questions