Blockproc handle function problem

1 view (last 30 days)
Putra A
Putra A on 25 Apr 2012
Hello i have a question about using blockproc i have create this code, its a simple blockproc usage i took this from example file :
% read image
awal = imread('h.jpg');
% global threshold
global_thres = graythresh(awal);
% callback function
fun=@(block_struct)...
im2bw(block_struct.data,graythresh(block_struct.data));
% partition
info_gambar = imfinfo('h.jpg');
tinggi = info_gambar.Height/5;
lebar = info_gambar.Width/5;
I2 = blockproc(awal,[tinggi lebar],fun);
figure;
imshow(awal);
figure;
imshow(I2,[]);
in this part of code i know that we can set a custom callback function for each block created by blockproc, but if i use this code i cant add an if else condition, i want to use if else condition to determine threshold method for each block. this is a pseudocode i want to achieve
if global_threshold > then otsu local threshold on block
use otsu threshold
else
use other threshold method
end
is there a clue for me to do this ? what i have to do with the code, i am new to matlab and maybe the solution is a kind of very basic things on matlab, any answers will help.
Thank you Regards, Putra

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!