필터 지우기
필터 지우기

doubt on using blkproc functiom

조회 수: 3 (최근 30일)
ramya raj
ramya raj 2011년 9월 2일
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);

답변 (2개)

Andrei Bobrov
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
Andrei Bobrov
Andrei Bobrov 2011년 9월 2일
Give part of your data
ramya raj
ramya raj 2011년 9월 2일
hai this is the data that i have
and the code i have used
clc;
clear all;
close all;
fundus=imread('D:\10mcs010\im0001.ppm');
grayImage=fundus(:,:,1);
[rows columns numberOfColorBands] = size(grayImage);
figure,imshow(grayImage);
title('Original Grayscale Image');
binaryImage = grayImage > 35;
A=[0 0 0;1 1 1;0 0 0];
op=imopen(binaryImage,A);
clos=imopen(op,A);
eror=imopen(clos,A);
maskedRgbImage = bsxfun(@times, fundus, cast(eror,class(fundus)));
g=maskedRgbImage(:,:,2);
imv=conv2(double(g),[1 0 -1],'same');
figure,image((imv));
title ('vertical image');
imh=conv2(double(g),[1;0;-1],'same');
figure,image((imh));
title ('horizontal image');
ev=abs(imv);
eh=abs(imh);
edgediff=imsubtract(ev,eh);
edgediff=double(edgediff);
erore=double(eror);
g=double(g);
final2=edgediff ./erore;
figure ,imshow(final2);
[width, height] = size(final2);
B=blkproc(final2,[30 height],@(x)sum(x(~isnan(x)&~isinf(x))));
and this is the answer i am getting i don't know where is the error
-44907
-13744
-9499
-1979
822
1502
-3559
12038
6991
14429
9999
8073
9060
4894
-3508
-8374
-51
-3687
-1323
-38133
0

댓글을 달려면 로그인하십시오.


Bjorn Gustavsson
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

카테고리

Help CenterFile Exchange에서 Camera Calibration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by