Calling function for blockproc

1 回表示 (過去 30 日間)
Pa342
Pa342 2018 年 4 月 21 日
コメント済み: Pa342 2018 年 4 月 23 日
I want to create a calling function for blockproc, where I obtain the number of connected objects inside each block of the image. B1 is my image, a logical returned after converting my image to black and white based on a threshold. The relevant code is here:
func = @blockfun
blockSize = [16 16];
blockyImage8 = blockproc(B1, blockSize, func);
And the function is here:
function x = blockfun(a)
CC = bwconncomp(a,8);
x = CC.NumObjects;
end
I get the error message:
Error using bwconncomp
Expected input number 1, BW, to be one of these types:
logical, double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64
Instead its type was struct.
Any advice?

採用された回答

Stephen23
Stephen23 2018 年 4 月 21 日
編集済み: Stephen23 2018 年 4 月 21 日

As its help explains, blockproc supplies a structure to the called function. The fields of the structure are listed in the help. Possibly you want the data field:

CC = bwconncomp(a.data,8);
  1 件のコメント
Pa342
Pa342 2018 年 4 月 23 日
thanks, I understand now.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by