ccfun.m

버전 1.0.0.0 (1.64 KB) 작성자: Herbert
Apply a function to connected components in one or more images
다운로드 수: 130
업데이트 날짜: 2014/6/19

라이선스 보기

ccfun Apply a function to connected components in one or more images

S = ccfun(fun, cc, I) applies fun to each connected component in cc and
I. I is a MxNxC matrix, typically C=1 or C=3 for RGB, and cc is a cell
where each element defines the indices of one connected component. That
is:

S(i) = fun(I(cc_x(i), cc_y(i), :))
where [cc_x(i), cc_y(i)] = ind2sub(size(I), cc{i});

S = ccfun(fun, cc, I1, ..., In) Similar, but now

S(i) = fun(I1(cc_x(i), cc_y(i), :), ..., In(cc_x(i), cc_y(i), :))

For efficiency this function uses no for-loops.

The application of the function is done using cellfun and cell2mat, fun
must return a uniform output.

Example:
I = rand(100, 100); % Some image
cc = {randi(100*100, 20, 1)}; % A conneted component with 20 pixels,
% probably not really connected ;)
cellfun(@(x) sum(x), cc, I)

ans =

13.0654

sum(I(cc{1}))

ans =

13.0654

Author: Herbert Kruitbosch
Copyright: Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)
http://creativecommons.org/licenses/by-nc-nd/4.0/

If you want to change and share something in the script, e-mail me an
updated version and I may consider it.

인용 양식

Herbert (2024). ccfun.m (https://www.mathworks.com/matlabcentral/fileexchange/47004-ccfun-m), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2013b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Region and Image Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0