doubt on using blkproc functiom
1 次查看(过去 30 天)
显示 更早的评论
hai i am working with matlab R2009a and i have to move a window of size[30,700] over the image and calculate the sum of pixels inside the window
the problem is my image is having NaN values and and i am using the blkproc function to make the window move over my image and i got a matrix of size 21X700 with NAN values is my answer correct please some one help me
and my coding is this
figure ,imshow(final2); [width, height] = size(final2); fun=@sum; B=blkproc(final2,[30 height],fun);
0 个评论
回答(2 个)
Andrei Bobrov
2011-9-2
variant
B=blkproc(final2,[30 height],@(x)sum(x(~isnan(x))));
OR
B=blockproc(final2,[30 height],@(block_struct)sum(block_struct.data(~isnan(block_struct.data))));
add variant
B=blkproc(final2,[30 height],@(x)sum(x(~isnan(x)&~isinf(x))))
3 个评论
Bjorn Gustavsson
2011-9-2
Replace sum with nansum in your call to blkproc. If you dont have the statistics toolbox you can look for nansum in the file exchange - I've found at least one statistics-related toolbox there that includes a number of nan-safe functions.
HTH
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!