Block structures and image processing
이전 댓글 표시
Hi I'm trying to write some code that achieves the following using the image processing toolbox:
1. Split a grayscale image (I) into blocks
2. Calculate the mean value of each block
3. For each element within each block, if it's > the mean of that block colour it black, if not colour it white.
Here's what I want to say:
fun=@(block_struct)...
for n=1:32
for m=1:32
if block_struct.data(n,m)>(mean2(block_struct.data));
block_struct.data(n,m)=0;
else
block_struct.data(n,m)=255;
end
end
end
I2=blockproc(I,[32 32],fun);
imshow(I2)
However you cannot have anonymous functions with more than one statement and I'm not sure how to use a block structure with a normal function. I have looked a little into nested functions but I haven't found an answer yet. Any help would be appreciated.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Neighborhood and Block Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!