MATLAB Answers

Using a user defined fucntion with blockproc

조회 수: 11(최근 30일)
Jason
Jason 15 Jan 2015
댓글: Jason 15 Jan 2015
Is there a mistake in my syntax using blocproc:
Binary1=blockproc(OrigImage,[tileRowSize, tileColSize],@(x) myOperation(hObject, eventdata, handles, x.data));
the function I use "myOperation" is as follows:
function myOperation(hObject, eventdata, handles,tile)
[thresh1, thresh2] = Threshold(hObject, eventdata, handles,tile); %my personal thresholding function
%Create Binary Image
size(tile)
ix=tile;
level=thresh2
ix(ix<level)=0;
ix(ix>level+1)=1;
Im getting
Binary1 =
[]

  댓글 수: 0

Sign in to comment.

답변(2개)

Image Analyst
Image Analyst 15 Jan 2015
I don't have time to look at it now, but in the meantime, see my blockproc demos, attached.

  댓글 수: 0

Sign in to comment.


Iain
Iain 15 Jan 2015
What does your "myfunction" function output? It looks like it's not producing any output.

  댓글 수: 4

표시 이전 댓글 수: 1
Jason
Jason 15 Jan 2015
Now I have the blockproc approach thanks to everyones kind help, I can see by comparison to the subdivision using looping (as initially suggested by IA) is almost the same , but not quite!
Comparing the two binary images obtaine dby these two approachs with the raw image in the highlighted boxes I can see that consideration of the additional row/column via blocproc seems to be falsely picking out objects.
I also notice using the blockproc approach (my raw image is 101x101, and Im using 25x25 in blockproc), that the very last pixel is the actual grayscale and not binarised?
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 1 1 1914
Image Analyst
Image Analyst 15 Jan 2015
If you have blocks of 25 pixels by 25 pixels, and you move in "jumps" of 25 pixels, then I believe your last block will have only 1 row or column. Thus it may not have a value like the others that had a full block in them.
Jason
Jason 15 Jan 2015
Yes that makes sense.
Is it possible to return also the mean intensity of each sub image using blockproc, I thought I could just add an extra output variable from my function such as:
function [BI, mn] = myOperation(hObject, eventdata, handles,tile)
mn=mean(tile)
%then the rest of the code.
and then obtain a matrix of mean values via:
[Binary1, mn]=blockproc(OrigImage,[tileRowSize, tileColSize],@(x) myOperation(hObject, eventdata, handles, x.data));
But it complains about too many output arguments for Blockproc.

Sign in to comment.


Translated by