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!