How to draw a directed arrow line in Java?

Although Pete’s post is awesomely comprehensive, I’m using this method to draw a very simple line with a little triangle at its end. // create an AffineTransform // and a triangle centered on (0,0) and pointing downward // somewhere outside Swing’s paint loop AffineTransform tx = new AffineTransform(); Line2D.Double line = new Line2D.Double(0,0,100,100); Polygon arrowHead … Read more

Matlab: How to bend line in image

Ok, here is a way involving several randomization steps needed to get a “natural” non symmetrical appearance. I am posting the actual code in Mathematica, just in case someone cares translating it to Matlab. (* A preparatory step: get your image and clean it*) i = Import@”http://i.stack.imgur.com/YENhB.png”; i1 = Image@Replace[ImageData[i], {0., 0., 0.} -> {1, … Read more

How to draw a line on an image in matlab?

The simplest way to draw a line onto an image is to use PLOT. %# read and display image img = imread(‘autumn.tif’); figure,imshow(img) %# make sure the image doesn’t disappear if we plot something else hold on %# define points (in matrix coordinates) p1 = [10,100]; p2 = [100,20]; %# plot the points. %# Note … Read more

Get a single line representation for multiple close by lines clustered together in opencv

If you don’t know the number of lines in the image you can use the cv::partition function to split lines on equivalency group. I suggest you the following procedure: Split your lines using cv::partition. You need to specify a good predicate function. It really depends on lines which you extract from image, but I think … Read more

Using awk to pull specific lines from a file

awk ‘NR == FNR {nums[$1]; next} FNR in nums’ numberfile datafile simply referring to an array subscript creates the entry. Looping over the first file, while NR (record number) is equal to FNR (file record number) using the next statement stores all the line numbers in the array. After that when FNR of the second … Read more