doubt on using blkproc functiom
1 view (last 30 days)
Show older comments
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 Comments
Answers (2)
Andrei Bobrov
on 2 Sep 2011
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 Comments
Bjorn Gustavsson
on 2 Sep 2011
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 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!