OpenCV - Leaf Petiole Removal [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I would like to know how can I approach my given problem: removing petiole from a leaf, with very little to none effects to the leaf.
From research, people tried using morphological operations like top-hat to enhance and remove the petiole afterwards, but in some cases this doesn't work so well, detecting in addition peaks from the leaf (example below).
I will try also segmentation based on HSV color space, but i will very much appreciate an idea for BGR space.
From left to right (input image, contour found, morphological applied with a kernel size structuring element which depends for every leaf species)
I am using OpenCV with C++.
example problem petiole detection

As mentioned in the comments I was curious to try this out myself.
And this is what I got:
I used the distance transform, but the final solution does not appear so perfect. I have the code in python if you would like.
CODE:
dist_transform = cv2.distanceTransform(thresh1,cv2.DIST_L2,5)
ret, stalk = cv2.threshold(dist_transform,0.095*dist_transform.max(),255,0)
stalk = np.uint8(stalk)
cv2.imshow('stalk_removed.jpg',stalk)
Where thresh1 is the binary image of the leaf.

Related

Histogram calculation for rotation invariant local binary pattern in opencv c++ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have been working on a opencv project that requires calculation of histogram for rotation invariant local binary pattern.I checked github and bytefish git repos but cant find what i am looking for.
Exactly what i want to say is that once i find the lbp image of any video frame or image, how to make it rotation invariant lbp and find its histogram as texture feature that can be further used for training or classification.
Can someone tell me how to exactly find the histogram for rotation invariant LBP and histogram for uniform rotation invariant LBP in opencv c++.
Thankyou!

Detect High density pixel areas in a binary image [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am doing background subtraction, and I obtain a binary image with foreground objects and with some noise.
I want to obtain a ROI for each object on the binary image and them analyze it to ensure that is the object that I want.
How do I segment only the areas with high pixel intensity (objects)?
One example of obtained image:
Have a look at openCv simpleBlobDetector, there are several configurable parameters to it and tons of tutorials online.
The documentation can be found here: http://docs.opencv.org/trunk/d0/d7a/classcv_1_1SimpleBlobDetector.html
Alternatively you could just convolve a white rectangle across multiple scale spaces and return the median values over each scale space.

Detect U Shaped Edges in an Image [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to detect the location of a fingertip from an image. I've been able to crop out a region in the image where it must have a fingertip, and extract the edges using Canny Edge Detector. However I'm stuck. Since my project description says I can't use the skin color for detection, I cannot find the exact contour of the finger, and will have to try to separate the fingertip with edges alone. Right now I'm thinking since the finger has a curved arch shape/letter U shape, maybe that could be used for detection. But since it has to be rotation/scale invariant, most algorithms I found so far are not up to it. Does anyone have an idea of how to do this? Thanks for anyone that responds!
This is the result I have now. I want to put a bounding box around the index fingertip, or the highest fingertip, whichever is the easiest.
You may view the tip of U as a corner, and try corner detection method such as the Foerstner Algorithm that will position of a corner with sub-pixel accuracy, and Haris corner detector which has implementation included in the feature2D class in opencv.
There is a very clear and straighforward lecture on Haris corner detector that I would like to share with you.

Gradient along a path [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Is it possible to create something like this in inkscape? I have been searching and trying for quite some time, but so far no results...
So what I am looking for is a gradient which follows the direction of the path it is applied to.
Gradient along a path http://coreldraw.com/cfs-filesystemfile.ashx/__key/CommunityServer.Components.PostAttachments/00.00.02.07.23/GradientBlend2.jpg
I am not aware of a solution that perfectly satisfies your needs however here is one approach to get close:
Draw a line, open the Fill and Stroke dialog and set the width of the stroke (Stroke style tab) to 50. Transform the stroke to a path (Path > Stroke to Path).
Fill the path with a linear gradient (Fill and Stroke dialog > Fill > Linear gradient) and choose any colours you like.
Select the node tool (F2) and a line will appear stretching the area of your shape (marked with an exclamation mark on the picture below). Adjusting this line may help you to fine tune the gradient (however, strictly speaking it will not follow the path but a rectangle defined by the start and end marker of the marked line)
This should work for simple shapes that do not reverse. Let me know if this is good enough or if you need more detailed instructions.

How to draw clothoids graphically in Qt? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I am trying to build an application which the user can use to draw clothoids with the mouse, i.e. to set the start point and the end point of the spiral and then by dragging these points with the mouse he could also set the shape of the clothoid by modifying the start and end curvature. Probably for changing the curvature I will need to use the tangents though I am not sure of that.
How can one implement that in Qt? Do you know of any example codes that I could run in Qt?
The best approach would probably be to use the Graphics View Framework.
There are a few examples that should help you getting started in the Graphics View Examples page. The Diagram scene one looks like a good starting point for what you want to achieve.
I realize that this is an old question, but for interested parties there is a good discussion of theory and pseudocode for Euler spirals (clothoids) in the paper "Euler Spiral for Shape Completion" by Kimia, Frankel, and Popescu. Sample C++ code can be found online at Brown University's website.
Euler Spiral for Shape Completion
Page with download link for C++ code for method of Kimia, Frankel, and Popescu
Papers by Levien and others suggest methods to improved upon the "biarc" calculation of the paper by Kimia, et al. Levien's paper includes an in-depth history.
The Euler spiral: a mathematical history by Raph Levien
You only need four parameters to draw the spiral: two end points, and the angles of tangents at those end points. (You don't need to define curvature.) The code outputs the intermediate points between the two end points at distance increments of your choice. You simply need to plot and connect those intermediate points.
Once you implement the code, you may need to tweak some of the parameters such as the minimum curvature. You'll likely see a few parameters for which the code "blows up".