finding the coordinates of points with maximum intensity

i have a image file of a welded metal in jpg format. In the image ,the defect in welding appears as an object having maximum intensity.I need a code that can convert the coordinates having intensity above a certain given threshold to '1' and all other points below threshold to '0'. please help. thanks

 채택된 답변

Mohammad Abouali
Mohammad Abouali 2014년 10월 16일
편집: Mohammad Abouali 2014년 10월 16일
If "I" is your intensity image and your threshold is stored in "thresh" pretty much all you need to do is:
mask= I>Thresh
Mask would have 1 for every pixel that has the intensity more than the threshold and the rest would be zero.

댓글 수: 16

thanks Mohammad, by intensity image u mean my jpg image?
Yes, make sure that your jpg image is truly one layer. If it is not there are various way to change it to that.
my image is a colored image
Guillaume
Guillaume 2014년 10월 16일
편집: Guillaume 2014년 10월 16일
In that case assuming that what you're calling intensity is the luminance, first convert your image to greyscale with rgb2gray.
Alternatively, you can call im2bw which will do the conversion and thresholding for you.
If you mean something else for the intensity of a colour image, you'll have to define it for us.
Mohammad Abouali
Mohammad Abouali 2014년 10월 16일
편집: Mohammad Abouali 2014년 10월 16일
As Guillaume said, you can use rgb2gray to turn it into intensity map. But that is one option.
Could you upload a sample image? If you don't have a predefined threshold you can use graythresh or multithresh. Depending on your case detectMSERFeatures may be also appropriate.
Also play with the tool that ImageAnalyst has uploaded it gives you some idea.
Thanks Guillaume. Mohammad i am uploading the image i have(bmp format) .sorry, by mistake i wrote .jpg earlier.
This is what I got using colorThresholder of matlab
Use colorThresholder and you can export the function. You can use the exported function as follow:
I=imread('test S-scan.bmp');
[BW,maskedRGBImage] = createMask(I);
I have attached the createMask.m for you.
Unfortunately the image you uploaded is already pseudocolored (it has a color map applied to it, plus other lines and annnotations). So you can't simply threshold that. You can threshold the original gray scale image , which presumably you have. Otherwise you can use the color threshold tool like Mohammad showed you but of course it's best to use the original image, not a pseudocolored one. You definitely can't use rgb2gray() to convert the pseudocolored image into the original gray scale image.
In addition to what Image Analyst said (don't use pseudocolours), it looks like you're using some sort of jet / rainbow colour map. That is probably the worst colour map to use.
actually the image that i uploaded has been generated by tomoview software. Input to this software was from a phased array ultrasonic scan . Tomoview software gives you a image file in .opd format. We converted it to bmp format so that it can be used in matlab as opd format doesn't works in matlab. as image analyst said it is pseudocolored and i can't use rb2gray(). Also, i don't have original grey scale image. So what can i do.
If you can fix the min/max levels that are mapped to the colormap that is being used, when converting to bmp than you can use the colorThresholder to generate the levels for you as I did above and keep using the same threshold.
However, if you have no control the work is a bit more difficult.
I was able to plot the binary image file displaying the defect by using a matlab code that makes use of thresholds obtained from the colorThreshold app. Also i was able to input multiple images in a sequence and see their corresponding binary images. Is their any way i can calculate the number of points in EACH individual defect in the image? Image that we are using here, has more than one defect. By running a for loop i can only count the total number of points (i.e. points in all 3 defects in our image added together) .
regionprops() does that. It gets the area of each blob. To get the area of all blobs in an image you can either sum the area of each blob, or just sum the white pixels:
numWhitePixelsInImage = sum(binaryImage(:));
Of course you can add those numbers from separate images if you want to do that.
Image Analyst, my question is like this... an ultrasonic scanning probe is hovered above a metal rod to scan for defects.The scan can be seen on display connected to this probe. This scan is a colored video in which the defects are red colored. My aim to track the red colored spots in real time and generate a signal 1/0. I mean as we move the probe across the length of rod our algorithm should give a signal immediately whenever there is a red spot. the video generated by probe is 60 frame/sec. Also this video is not stored as file,we see video as we scan rod. I do not need to show the red spots ,but instead generate a signal 1 for red spot and 0 for no red spot. How can this be achieved,any idea. Thanks
This (color tracking) seems like enough of a different question that it should be on its own, rather than as part of this one on thresholding, which has already been marked as solved. Please make a new question and post an image.
ok,i have made a different question for this. Thanks

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 10월 16일

6 개 추천

This is just what my Image Segmentation Tutorial does. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 Then it goes beyond that - it also finds centroid, area, etc. and crops out the regions. Adapt it as needed.

댓글 수: 3

There should be a thumbs up button for MATLAB answer. Nice tool.
You can click on the Vote triangle under the user's avatar. Thanks!
Nice. I never saw that before.

댓글을 달려면 로그인하십시오.

질문:

2014년 10월 16일

댓글:

2014년 11월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by