MATLAB Answers


How to threshold in this.?

Asked by Lalit Patil on 16 Feb 2013

 clear all;
 I = imread('2.png');
 threshold = graythresh(I);
 originalImage = im2bw(I, threshold);
 i = bwareaopen(originalImage,70);
 TI = imfill(i, 'holes');

I want to detect only the strip which is on object.?

This code not works.

Is there any other method or modification..?


I wasn't able to download your image. It saves it but it doesn't save it as a real PNG image even though the extension is PNG.

i have changed link..

1 Answer

Answer by Image Analyst
on 16 Feb 2013
Edited by Image Analyst
on 16 Feb 2013
 Accepted answer

Don't use graythresh(). Pick your own threshold, perhaps using my interactive thresholding function that's in my File Exchange.


yes it, works at min=88 and max=233,

but i want code for this..

binaryImage = grayImage >= 88 & grayImage <=233;

Very helpful Demo...:) It Solves many problems...

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!