how to dilate the gray scale image and threshold value only on ROI?

I have a gray scale image that has several objects in it. can anyone tell me how to apply threshold only to one object( which is my ROI) in the image?

 Respuesta aceptada

Susan
Susan el 10 de Abr. de 2013
If you created an ROI object, you can create a binary mask from the ROI. Then, you can specify an arbitrary image matrix where the values corresponding to where the mask = 1 are the original gray values, and all others are zero. You can then threshold the new image, since it only contains your ROI, with all other pixels being black. Finally, reverse the process and in the original image, say that anywhere the mask = 1 is now equal to the new, thresholded, image values.
In order to explain this better, I'd have to know more about your code. What function are you using to get your ROI?

5 comentarios

Why not use BW = roipoly(); so that you can select an ROI that contains just the bone? It will return a binary mask for you as the output, which you can then use to do the thresholding, as described above. Otherwise, have you tried edge detection to detect only the bone region and create a binary mask that way? Canny edge detection might work. If you wanted to upload the image somewhere, I could take a look at it and advise you more.
BV
BV el 10 de Abr. de 2013
Editada: BV el 10 de Abr. de 2013
Í have a stack of images in which the position of the bone keeps changing. So I want to use an automatic method to detect bone. ´roipoly` becomes a manual function like for every image I got to select ROI. Here is the link of one such http://imageshack.us/v_images.php
I am unable to access the image, even with an imageshack account.
No good for me either. Try another site like tinypic, picturepush, snag.gy, etc. Or look here: http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers

Iniciar sesión para comentar.

Más respuestas (1)

BV
BV el 10 de Abr. de 2013
My image is an orthopaedic one (CT image), in which I have a bone and other objects. I created a mask with imellipse , within which I still have more than one object inside it. I want to apply threshold only to the bone and not other objects. The pixel intensties inside bone and the pixel values of the objects are too close to fix the threshold value. goal is to detect just the bone.

8 comentarios

This should have been a comment to Susan's answer, not an answer in itself. Where did you upload your image to? (Try http://snag.gy for an easy way.) You can mask an image like this:
% Mask the image.
maskedImage = bsxfun(@times, grayImage, cast(mask,class(grayImage)));
BV
BV el 10 de Abr. de 2013
Editada: BV el 10 de Abr. de 2013
I have uploaded my picture here :
I just vwant to detect bone and eliminate others.
Mask out the circle - that looks fixed. Then try to threshold for dark things and do some clean up. Might have to call bwareaopen() to get rid of small junk.
I did masking using 'imellipse'. When I threshold some information of the bone is lost, since the pixel intensity inside bone is present in the frame(rod like structrues).
Currently I am trying to dilate and erode with 'diamond' of '12' parameter to get rid of the unwanted regions and apply threshold.
I will try bwareaopen() also. thanks!
After masking and possibly after dilating and eroding with the diamond of radius 12 structuring element, I'd suggest doing marker-controlled watershed segmentation. The following link will take you to a help document about it. http://www.mathworks.com/help/images/examples/marker-controlled-watershed-segmentation.html I tried the algorithm on your image and it looks like it could work well with some modifications. After watershed segmentation you could subtract off the two largest areas it finds (using regionprops to find the largest areas), as they would correspond to the black mask background and the remaining image background. Then, you could create a bone-only mask from the remaining watershed regions found.
The only other thing I could suggest to find the bone most accurately is to define an initial contour with roipoly or roipolyold instead of using imellipse, and doing segmentation with active contours. The basic Kass snake works well as long as the initial contour is relatively close the object of interest. To account for motion in the images over time, you could find the average image and select the initial contour on that. Then, have the contour actually deform on the individual images.
thanks Susan!) I tried connecting components , label & regionprops to get just the bone.
Now I would like to try finding the weighted centroid of the bone and the other object(noise at the other end) and track the bone as it keeps shifting in every image. In otherwords, kind of object trackng.
I know it's been a while, but just wanted to check in and see if you found something that would work for tracking the bone and the noise object? I'm curious, as I may need to do some sort of object tracking down the line for the projects I work on.

Iniciar sesión para comentar.

Preguntada:

BV
el 10 de Abr. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by