Got Questions? Get Answers.
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

Thread Subject:
Thresholding by actual pixel value threhsold.

Subject: Thresholding by actual pixel value threhsold.

From: Shriniket Sarkar

Date: 13 Jan, 2011 20:10:20

Message: 1 of 4

Hello All,
           I have an Image and i ran an imhist on it. I got a threshold value based on the intensities. Its a gray image. What i want to do is try and threshold at this value. I.e. i want to make all the pixels with value more than the threshold value to say 255 so that rest all above the threshold turn white.
           I didnt this using nested for loops as follows :

for i=1:size(Img,1)
    for j=1:size(Img,2)
        if Img(i,j) > str2num(Hist_Threshold)
            Img_th(i,j) = 255;
        end
    end
end
Now i realize this is a very crude way of doing this. What i need is a way to make this same functionality to work at a faster rate .This approach takes lot of time as the images are big.
Is there any function to do so directly. I mean like a filter?

Subject: Thresholding by actual pixel value threhsold.

From: Sean de

Date: 13 Jan, 2011 20:23:05

Message: 2 of 4

"Shriniket Sarkar" <shriniketsarkar@gmail.com> wrote in message <ignm7c$o4t$1@fred.mathworks.com>...
> Hello All,
> I have an Image and i ran an imhist on it. I got a threshold value based on the intensities. Its a gray image. What i want to do is try and threshold at this value. I.e. i want to make all the pixels with value more than the threshold value to say 255 so that rest all above the threshold turn white.
> I didnt this using nested for loops as follows :
>
> for i=1:size(Img,1)
> for j=1:size(Img,2)
> if Img(i,j) > str2num(Hist_Threshold)
> Img_th(i,j) = 255;
> end
> end
> end
> Now i realize this is a very crude way of doing this. What i need is a way to make this same functionality to work at a faster rate .This approach takes lot of time as the images are big.
> Is there any function to do so directly. I mean like a filter?


Img(Img>threshold) = 255;

Subject: Thresholding by actual pixel value threhsold.

From: Shriniket Sarkar

Date: 13 Jan, 2011 20:38:05

Message: 3 of 4

Thanks a ton Sean de... I really dont believe I missed that. Thanks a lot.


"Sean de " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <ignmv8$g04$1@fred.mathworks.com>...
> "Shriniket Sarkar" <shriniketsarkar@gmail.com> wrote in message <ignm7c$o4t$1@fred.mathworks.com>...
> > Hello All,
> > I have an Image and i ran an imhist on it. I got a threshold value based on the intensities. Its a gray image. What i want to do is try and threshold at this value. I.e. i want to make all the pixels with value more than the threshold value to say 255 so that rest all above the threshold turn white.
> > I didnt this using nested for loops as follows :
> >
> > for i=1:size(Img,1)
> > for j=1:size(Img,2)
> > if Img(i,j) > str2num(Hist_Threshold)
> > Img_th(i,j) = 255;
> > end
> > end
> > end
> > Now i realize this is a very crude way of doing this. What i need is a way to make this same functionality to work at a faster rate .This approach takes lot of time as the images are big.
> > Is there any function to do so directly. I mean like a filter?
>
>
> Img(Img>threshold) = 255;

Subject: Thresholding by actual pixel value threhsold.

From: Shardul

Date: 3 Jan, 2013 07:11:12

Message: 4 of 4

"Shriniket Sarkar" <shriniketsarkar@gmail.com> wrote in message <ignm7c$o4t$1@fred.mathworks.com>...
> Hello All,
> I have an Image and i ran an imhist on it. I got a threshold value based on the intensities. Its a gray image. What i want to do is try and threshold at this value. I.e. i want to make all the pixels with value more than the threshold value to say 255 so that rest all above the threshold turn white.
> I didnt this using nested for loops as follows :
>
> for i=1:size(Img,1)
> for j=1:size(Img,2)
> if Img(i,j) > str2num(Hist_Threshold)
> Img_th(i,j) = 255;
> end
> end
> end
> Now i realize this is a very crude way of doing this. What i need is a way to make this same functionality to work at a faster rate .This approach takes lot of time as the images are big.
> Is there any function to do so directly. I mean like a filter?
The func. is
im2bw(I,level);
returns a binary image

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us