Could someone help me to find what morphological operations should I use in order to smoothen the vertical and horizontal rectangle on this image
More precisely what I would want is that the white rectangles become continuous. The final application of that would be to detect vertical and horizontal lines in the image, indeed this image is a map where white element represent obstacle and where i would want to detect the walls.
So the result i would want should be something like that:
Related
My image is something like below:
I want to be able to draw 2 layers: (1) red line on top of 1st layer, but (2) blue line in the middle of 2nd layer
I am using OpenCV. but any languages/advice are welcomed.
You can do the following:
Small closing in order to reconnect the small separated components/patterns.
Small opening in order to remove the small isolated components/patterns.
Skeletonize (or median axis)
Pruning in order to remove the small branches.
You will then get a skeleton for each pattern. It will be close to the lines you want to draw. But it will be a little bit irregular, so you can interpolate it.
[EDIT] if you need the red line on top of the edge, a solution is to:
Extract the pattern contour
Keep only the pixel on top.
Algorithmically, it can be achieved doing this: for each X coordinate on the top border, go down the image vertically until you meet the first non-null pixel. If your image is NxM, you must have N pixels in your solution.
If you want to regularize/smooth the result, you have two solutions:
Transform the contour as a parametric function and smooth it.
Do an interpolation (spline?)
I have an image like this.note that the regions are not perfectly shaped.it is rectangular like region and ellipse like region. I have segmented the ellipse like region using some algorithm.segmented region is bright one.the border (red rectangle) is dark one
finally i must get red rectangular like region
can you suggest any algorithm to perform this
I see that you have done some real progress on your segmentation. Because you already have an idea of the location of elements you want to segment, you should use a watershed with constraints/markers:
Your actual segmentation represents the inner markers.
You dilate it with a big structuring element (bugger than the inter disk space).
You take the contour of the dilation, and that's your outer markers.
You compute the gradient of the original image.
You apply the watershed on the gradient image, using the markers you have just computed.
[EDIT] As the segmentation you provided does not match with the original image (different dimensions), I had to simulate roughly a simple segmentation, using this image (the red lines being the the segmentation you already have). And I got this result.
I am analyzing back bone formation in zebrafish embryos and in this picture:
I would like to extract the shape and position of the horizontal lines/curves. Here is a little information about the image. The image at the top is already a segmented image through morphological processing and by using the MATLAB active contour function. The region between the two vertical lines is where the spinal cord develops and the horizontal lines on either side of the spinal cord later develop into ribs. The image at the bottom is where I have applied a canny edge detector. I have a time series of the development of ribs and I would now like to extract the shape and position of the horizontal curves. This is a follow up of my previous question:
Identify curves in binary image
I am guessing this will involve some kind of curve fitting module to obtain the shapes. Any ideas to go about this is very welcome.
Thanks
Consider that I have a colored image like this in which the outline is not complete (There are gaps between lines). I want to be able to fill the area between the lines with one color or another. This actually is a binary image which I got after applying canny edge detector on a corresponding gray scale image.
I tried first dilating the image and then eroding it, but the result is not good enough. I want to be able to preserve the thickness of the root
Any help would be greatly appreciated
Original Image
Image after edge detection and some manual removal of pixels
Using the information in the edge image, I thought I would try to extract pixels from the original image of a certain color. For every white pixel in the edited image, I used a search space in the original image along the same horizontal line. I used different thresholds for R, G and B and I ended up with this
I'm not sure what your original image looks like. It would be helpful to see.
You have gaps between the lines because a line in your original image has two edges, one on each side. The canny algorithm is detecting them both. The Canny edge detection algorithm has at its heart the application of two Sobel kernels to calculate the gradient, one for detecting horizontal edges and one for detection vertical edges.
-1 0 +1
-2 0 +2
-1 0 +1
and
+1 +2 +1
0 0 0
-1 -2 -1
These kernels will present peaks for both sides of the line. One peak positive and one negative. You can exclude one side of the line by excluding the corresponding peak. After taking the gradient of each direction truncate any values below zero (set the values to zero) to remove the second peak. Then continue with the Canny edge detection as usual. This will result in the detection of only a single edge for each line instead of the two that you are seeing now.
I'll add a third approach now that I have seen the image. It looks like most of the information is in the green channel.
Green channel image
This image gives you a decent result if you simply apply a threshold.
Thresholded image with a somewhat arbitrary threshold
You can then either clean this image up by itself or use your edge image. To clean it up with the edge image you produced remove any white pixels that are more than a certain distance from one of your detected edges (create a Euclidean distance map from your edge image and use that to set any white pixels greater than a certain distance from an edge to black).
If you are still collecting images you may want to try to position the camera in a way to avoid the bottom of the jar (or whatever this is).
You could attempt to use a line scanning methodology. Start at the side and scan horizontally. When you hit an edge you assume you are in a root and you start setting the voxels to white. When you hit another edge you assume you are leaving a root and you start. There will be some fringe cases and you may want to add additional checks, such as limiting the allowed thickness of a root.
You could also do a flood fill style algorithm where you take a seed point in a root and travel up the root filling it in.
Not sure how well these would work as it depends on the image and I did not test it.
What I want to do is color an irregular shape when user touch within that path.
Same as flood fill. But I found that flood fill is too costly in case of performance/speed/memory. So I have an idea. I dont know how to implement it. CGContextFillPath fills an irregular shapes.
So my Question is can we get a bounding paths/border line of that shape so that we can color that region??
It sounds like you have an image with a shape in it, where all the pixels in the shape are one color, and the boundary of the shape is a different color.
If I understand you correctly, you would have to use a flood-fill algorithm to find the boundary of the shape so you could turn that boundary into a CGPath. There's no magic way to get a path for the boundary of the shape without looking at the pixels.