# How can find connected region in RGB images?

2 ビュー (過去 30 日間)
ali Jalil 2016 年 4 月 13 日

I have RGB, and i want to find connected regions in it?

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

### 回答 (2 件)

DGM 2024 年 4 月 11 日
This answer demonstrates how to generate a mask by box (range) or ellipsoid (distance) matching in RGB given a target color tuple.
I'm assuming the goal is to do something similar to grayconnected(), so the given example can be further expanded to include sampling from the image and selection of the region local to the sample point.
% inputs
tol = [0.2 0.3 0.3]; % pick some tolerance per axis
picklocation = [20 100]; % where to sample the color [x y]
sampleradius = 2.5; % for sample averaging (set to 0 to disable)
% show the image and mark the location
imshow(inpict); hold on
plot(picklocation(1),picklocation(2),'x')
% prepare inputs
inpict = im2double(inpict); % put the image in a consistent scale
tol = permute(tol,[1 3 2]); % reorient tuple along page axis
% sample the image
xw = picklocation(1) + r + (-r:r); % (sample offset) + (padding offset) + (window indices)
yw = picklocation(2) + r + (-r:r);
pickedcolor = sum(fk.*padded(yw,xw,:),1:2); % sample average
% these are global color selections
% perform box (range) selection in RGB
% perform ellipsoid (euclidean distance) selection in RGB
% restrict the selection to the local blob (magic wand behavior)
conn = 4; % connectivity
##### 0 件のコメント-2 件の古いコメントを表示-2 件の古いコメントを非表示

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

Image Analyst 2024 年 4 月 12 日
It's a generic, general purpose demo of how to threshold an image to find blobs, and then measure things about the blobs, and extract certain blobs based on their areas or diameters.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Or you can look up the tag "color segmentation". It's been discussed hundreds of times.

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

### カテゴリ

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

### Community Treasure Hunt

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

Start Hunting!

Translated by