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 日

2 投票

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 件のコメント

sandeep
sandeep 2014 年 10 月 16 日
thanks Mohammad, by intensity image u mean my jpg image?
Mohammad Abouali
Mohammad Abouali 2014 年 10 月 16 日
Yes, make sure that your jpg image is truly one layer. If it is not there are various way to change it to that.
sandeep
sandeep 2014 年 10 月 16 日
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.
sandeep
sandeep 2014 年 10 月 16 日
Thanks Guillaume. Mohammad i am uploading the image i have(bmp format) .sorry, by mistake i wrote .jpg earlier.
Mohammad Abouali
Mohammad Abouali 2014 年 10 月 16 日
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.
Image Analyst
Image Analyst 2014 年 10 月 16 日
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.
Guillaume
Guillaume 2014 年 10 月 16 日
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.
sandeep
sandeep 2014 年 10 月 19 日
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.
Mohammad Abouali
Mohammad Abouali 2014 年 10 月 19 日
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.
sandeep
sandeep 2014 年 10 月 27 日
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) .
Image Analyst
Image Analyst 2014 年 10 月 27 日
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.
sandeep
sandeep 2014 年 11 月 6 日
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
Image Analyst
Image Analyst 2014 年 11 月 6 日
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.
sandeep
sandeep 2014 年 11 月 6 日
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 件のコメント

Mohammad Abouali
Mohammad Abouali 2014 年 10 月 16 日
There should be a thumbs up button for MATLAB answer. Nice tool.
Image Analyst
Image Analyst 2014 年 10 月 16 日
You can click on the Vote triangle under the user's avatar. Thanks!
Mohammad Abouali
Mohammad Abouali 2014 年 10 月 16 日
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