I want to make straight line chart but with border-smoothed angles (joints) like in the image below:
Is it possible at all (interpolation is not working in this way)? JS example which I found is based on vuetrend - https://jsfiddle.net/nyh18bLq/426/
Vuetrend init code
Related
So this should be straight forward but I a not very familiar with OpenCV.
Can someone suggest a method to measure the distance in pixels (red line) as shown in the image below? Preferably it had some options like width of measurement (as demonstrated at the end and begining of the red line) or something of sorts. This kind of measurement is very common in software like ImageJ, I can imagine it should be somewhat trivial to do it in OpenCV.
I would like to take several samples accros the image width as well.
Greets
I am using openCV and learning about it
Your task is quite simple.
optional smoothing (Gauss filter) - you have to experiment with your data to see if it helps
edge detection (will transform image to lines representing edges) - for example cv::Canny
Hough transform to detect lines - openCV.
Find two maximum values (longest lines) in Hough transform
you will have two questions of straight lines, then you can use this information to calculate distance between them
Note that whit this approach image doesn't have to be straight. You will have line equations which you have to manipulate in smart way. If those two lines are parallel this there is simple formula to get distance between them. If they are not perfectly parallel then you have to take this int account and use information about image area to get average distance.
A simple way to find the width of the channel would be the following:
distance = []
h = img.shape[0]
for j in range(img.shape[1]):
line_top = 0
line_bottom = img.shape[0]
found_top = False
found_bottom = False
for i in range(h):
if img[i,j,0] > 0 and not found_top:
line_top = i
found_top = True
if img[h-i-1,j,0] > 0 and not found_bottom:
line_bottom = h-i
found_bottom = True
if found_top and found_bottom:
distance.append(line_bottom-line_top)
break
But this would cause the distance to take into acount the very small white speckles.
To solve this there are several options:
Preprocess the image using opencv morphological transformation.
Preprocess the image using opencv gaussian filter or similar.
Update the code to use a larger window.
Another solution would be to apply opencv's findContours.
I'm using colmap. I succeed to visualize a 3D sparse reconstitution from a video.
Now I have some new images from the same scene and I want to (only) localize them. I want the (x,y,z, angles) of the camera.
Following the doc, I used the commands colmap feature_extractor and colmap vocab_tree_matcher.
Everything seemed to get well; the output is
Indexing image [1/23] in 0,022s
...
Indexing image [23/23] in 0,077s
Matching image [1/16] in 0,078s
...
Matching image [16/16] in 0,003s
Elapsed time: 0,043 [minutes]
But now what ?
How do I query the colmap database to get the (x,y,z,angle) of image, say, 12 ?
I want to programmatically get the information.
I am trying to detect horizontal and vertical striped patterns in cloth pictures. Two examples of pictures that should be detected are:
My first approach was trying to use a Hough Line detector. The problem is the clothes are often deformed or wrinkled so the lines aren't straight and the detector fails.
It can be assumed that the lines are horizontal or vertical with a deviation of a few degrees (horizontal and vertical striped patterns). Also that the lines are parallel
What would be a good approach to detect such slightly deformed lines?
Convert the image to gray scale
Calculate the gradient (for example, using sobel)
Take horizontal and vertical projections of the gradient image
Threshold the projections and count the peaks
I quickly tried this in Matlab. You can try it with opencv. Use reduce function to take the projections. Below is the Matlab code and some results:
im = imread('pRfUL.jpg');
gr = rgb2gray(im);
h = fspecial('sobel');
grad = imfilter(gr, h) + imfilter(gr, h'); % quick gradient
hpr = sum(grad);
vpr = sum(grad');
figure,
subplot(2,2,1), imshow(gr), title('gray scale')
subplot(2,2,2), imshow(grad), title('gradient')
subplot(2,2,3), plot(hpr), title('horizontal projection')
subplot(2,2,4), plot(vpr), title('vertical projection')
EDIT
One possible improvement would be to consider horizontal and vertical cases separately. So, there would be two passes through the image for each cases (this might perform better for noisy/textured cases, and as Nallath pointed out- I think he's referring to bilateral filtering-, you can use some additional filtering). That is, when you look for horizontal strips, use the horizontal filter which will give strong responses for horizontally oriented edges. Same for vertical case.
grad = imfilter(gr, h); % for strong horizontal responses in the above code. use grad = imfilter(gr, h') for vertical
The result for horizontal case: note that the horizontal projection and the vertical offset have dropped significantly
I'm trying to do edge detection with SimpleCV on a RasPi by first finding all the lines in an image and then filtering items set based on location, intersect angle and color. I have the filtering figured out, but am having difficulty displaying the image with the filtered lines drawn in.
Currently I am can draw the full line set with
handle_lin = my_lines_full.draw()
handle_img = some_image.show()
and the filtered line set independently with
handle_lin = my_lines_filtered.draw()
handle_img = some_image.show()
but since this method also displays the full line set, no difference is seen when I do them in the same script. Whats the best way to erase the layer that stores the line drawings or selectively remove elements of the drawing?
Sovled(-ish):
Seems as though the some_lines.draw() command toggles line sets so by repeating the .draw() command before updating the lines set I can clear the layer that is displayed on the image.
If a user has defined curves or faces within a STEP file with colors, I'm able to read in the colors from the STEP file and create a list with this snippet:
Handle_XCAFDoc_ColorTool colorList = XCAFDoc_DocumentTool::ColorTool(STEPDocument->Main());
// List colors in the STEP File
TDF_LabelSequence colors;
colorList->GetColors(colors);
I am having trouble extracting a shape, assembly, or component based on a given color. Ideally, I would like to extract a TopoDS_Shape from a method that uses color in such a way that I can cycle through the list of colors and dump out a shape. Any thoughts? Any hints on classes to look at or strategies will be helpful.