フィルターのクリア

how to detect center of an object in an image and then crop the original image? using original image and green outline region

10 ビュー (過去 30 日間)
Hello.
I need to detect an object (suspicious area in an image). Then I need to find its centroid and then crop it the image into 256x256 pixels using image centroid as the centre of bounding box.
img = imread('1_245_original.jpg');
% colorspace
jmg = rgb2gray(img);
jm = mat2gray(jmg(:,:,1));
jm = imcomplement(jm);
% thresh
bw = imbinarize(jm, graythresh(jm));
% filter noise
bw = imopen(bw, strel('disk', 5));
bw = imfill(bw, 'holes');
% label every target
[L,num] = bwlabel(bw);
stats = regionprops(L);
figure; imshow(img, []);
for i = 1 : num
% get rect
recti = stats(i).BoundingBox;
% get cen
ceni = stats(i).Centroid;
% crop image
imi = imcrop(img, round(recti));
ims{i} = imi;
% rect and cen
hold on; rectangle('Position', recti, 'EdgeColor', 'c', 'LineWidth', 2);
plot(ceni(1), ceni(2), 'yp', 'MarkerFaceColor', 'y', 'MarkerSize', 20);
end
I have tried out this code, but the cropping area was not in 256x256 pixels. and I want it to save at folder after detect the bounding box. Where can I put that code? Thanks.
  1 件のコメント
Image Analyst
Image Analyst 2024 年 5 月 20 日
You've asked this before. Finding dark regions is not a problem, nor is cropping them and resizing them. The problem is identifying which of the many dark regions in the image is the specific one you want, and you haven't specified what it is about that dark blob that distinguishes it from all the other dark blobs. Yes, I know you've said that it is diseased tissue but how does it LOOK different than all the others?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by