Putri Ranati
Putri Ranati

Reputation: 47

How to find thresholds?

I read a MATLAB website called "Image Processing Made Easy". It references this code:

rmat=Im(:,:,1);
gmat=Im(:,:,2);
bmat=Im(:,:,3);

subplot(2,2,1), imshow(rmat);
title('Red Plane');
subplot(2,2,2), imshow(gmat);
title('Green Plane');
subplot(2,2,3), imshow(bmat);
title('Blue Plane');
subplot(2,2,4), imshow(I);
title('Original Image');

%%
levelr = 0.63;
levelg = 0.5;
levelb = 0.4;
i1=im2bw(rmat,levelr);
i2=im2bw(gmat,levelg);
i3=im2bw(bmat,levelb);
Isum = (i1&i2&i3);

How can we find a value levelr, levelg, and levelb?

Upvotes: 0

Views: 161

Answers (1)

oofin
oofin

Reputation: 160

Kind of late, but I've found that the built-in MATLAB function graythresh() works pretty well. It relies on Otsu's Method (pretty well-known, described in the documentation) and does well with imbinarize/im2bw.

eg,

levelr = graythresh(rmat)

and levelr will be a threshold between 0 - 1.0

Upvotes: 2

Related Questions