フィルターのクリア

Find center of pixels in an image?

3 ビュー (過去 30 日間)
Alberto Paniate
Alberto Paniate 2020 年 11 月 7 日
回答済み: Image Analyst 2020 年 11 月 12 日
Hi, I have a picture like "Cattura"
I want to find the center of those little areas that we can see.
How can I do?

採用された回答

Image Analyst
Image Analyst 2020 年 11 月 12 日
Try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 18;
fprintf('Beginning to run %s.m ...\n', mfilename);
echo off;
s = load('FileDaAllegare.mat')
grayImage = s.E;
subplot(2, 2, 1);
imshow(imadjust(grayImage), []);
title('Contrast-stretched gray scale image', 'FontSize', fontSize);
subplot(2, 2, 2);
imhist(grayImage);
grid on;
title('Histogram of gray scale image', 'FontSize', fontSize);
% Binarize the image.
mask = grayImage > 0.5;
% Count the initial number of blobs.
[~, numBlobs] = bwlabel(mask);
fprintf('Found %d blobs initially.\n', numBlobs);
% Merge close blobs together with a morphologcal closing.
windowRadius = 7;
se = strel('disk', windowRadius, 0);
mask = imclose(mask, se);
subplot(2, 2, 3);
imshow(mask, []);
title('Binary image', 'FontSize', fontSize);
props = regionprops(mask, 'Area', 'Centroid');
numBlobs = length(props);
% Get all the areas.
allAreas = [props.Area];
% Get all the centroids. Column 1 is x, column 2 is y.
centroidsXY = vertcat(props.Centroid);
fprintf('Found %d blobs after filtering.\n', numBlobs);
% Show histogram of areas.
subplot(2, 2, 4);
histogram(allAreas);
grid on;
caption = sprintf('Histogram of %d Blob Areas', numBlobs);
title(caption, 'FontSize', fontSize);
g = gcf;
g.WindowState = 'maximized';

その他の回答 (1 件)

Image Analyst
Image Analyst 2020 年 11 月 7 日
編集済み: Image Analyst 2020 年 11 月 7 日
I go over this in my Image Segmentation Tutorial
Attach your original gray scale image (not a pseudocolored screenshot) if you need more help.
  7 件のコメント
Image Analyst
Image Analyst 2020 年 11 月 10 日
Can you make easy on us and please attach it here with the paper clip icon? We'd like the solution to be completely self contained here within the Answers forum, not spread across different web sites. I'll check back later.
Alberto Paniate
Alberto Paniate 2020 年 11 月 11 日
I cant the dimension is 29 MB even zipping it

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

カテゴリ

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