Formula to unfold circle to straight line - - image-processing

I am looking for a simple conversion/transformation formula, such that:
In a square region sized d*d, containing a circle with diameter d (tangent to the 4 sides of the square),
all points on the circle are equidistantly transformed/unfolded/remapped into a straight line along the top or bottom edge of the square,
the center point of the circle is transformed/stretched all along the opposite edge of the square,
all points inside the circle are transformed the same way, and the resulting left and right sides can be tiled seamlessly, and
all points outside the circle are out of range of the square after the transformation, and are not visible.
In this before and after example, d=1:
Before After
------ -----
0 , 0 --> 0 , 1 (the only infinitely stretched point)
0 , -1 --> 0 , -1 (the only unchanged point)
0 , 1 --> -1 , -1 and 1 , -1
1 , 0 --> 1/2 , -1
-1 , 0 --> -1/2 , -1
√(1/2) , √(1/2) --> 3/4 , -1
√(1/2) , -√(1/2) --> 1/4 , -1
-√(1/2) , √(1/2) --> -3/4 , -1
-√(1/2) , -√(1/2) --> -1/4 , -1
1 , 1 --> out of range
1 , -1 --> out of range
-1 , 1 --> out of range
-1 , -1 --> out of range
This is related to polar/Cartesian (r,theta) to (x,y) conversion and/or arctan. The formula would be usable on graphing calculators like desmos.
For visual thinkers, here is a before & after graph of the transformation. Note that the circle before is along the bottom after, and that the transformed dots can be tiled horizontally.

Related

How Kitti calibration matrix was calculated?

I working with other dataset (no kitti), but I need to convert it in kitti dataset format. I can't understand how calibration matrices were calculated in kitti. Example:
camera 2 (P2) calibration matrix from calib.txt:
[718.856 0 607.1928 -386.1448]
[ 0 718.856 185.2157 0 ]
[ 0 0 1 0 ]
I know, that
[718.856 0 607.1928]
[ 0 718.856 185.2157]
[ 0 0 1 ]
-- are K - camera intrinsic. But what the last column mean?
I suggested, that it's an offset from 0-th camera, measured in pixels.
From kitti sensor setup, I know that Cam 2 offsets from Cam 0 for 0.06m negatively by axis X.
Camera pixel size is 4.65um. But
0.06[m] / (4.65 * 10^(-6)[m]) != 386.1448 [pixels]
So what does the last column mean? And how to calculate calibration matrix just like in kitti.
According to the file calib_cam_to_cam.txt(calib_time: 09-Jan-2012 14:00:15) provided on Kitti Website - http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=3d, the above mentioned matrix is for Camera 01(P_rect_01). As mentioned in the paper Vision meets Robotics: The KITTI Dataset by Andreas Geiger, Philip Lenz, Christoph Stiller and Raquel Urtasun(Section IV B - camera calibration), projection matrix for i-th camera -
P(i)rect = [[fu 0 cx -fu*bx],
[0 fv cy 0],
[0 0 1 0]]
where, bx is the baseline in meters w.r.t. the reference camera 0. The sensor setup as shown on Kitti website - http://www.cvlibs.net/datasets/kitti/setup.php indicates baseline between cam 3 and cam 2 is 0.54m and baseline between cam 0 and cam 2, and cam 1 and cam 3 is 0.06m.
Now, -fu*bx/fu = -386.1448/718.856 ~= -0.537165 ~= -0.54 (B3-2 - B2-0 + B1-3 = B1-0)

Highcharts custom pattern fill shows different stroke width

I'm trying to create a custom pattern fill for highcharts.
It's a horizontal dashed line with alternating starting points from one row to another (the first start at 0,0 the second at 3,10 and so on).
I edited the Highcharts JSfiddle example replacing the custom pattern with the following (here you can find my "final" version) :
color: {
pattern: {
path: {
d: 'M 0 0 H 8 M 14 0 H 22 M 3 10 H 19',
strokeWidth: 0.5
},
width: 22,
height: 20
}
}
The problem is the the two rows of lines have different width.
I can't find any parameter in the documentation to fix this.
I don't know if the problem is in my pattern definition or a highcharts bug.
Any thoughts?
The path as-is moves first to 0,0 and then 14,0, and finally 3,10:
d: 'M 0 0 H 8 M 14 0 H 22 M 3 10 H 19'
You can change that to 0,1 and then 14,1, and then 3,11 and the lines are the same width:
d: 'M 0 1 H 8 M 14 1 H 22 M 3 11 H 19'
The lines starting at 0,0 are centred on the boundary meaning that half the line gets cut off, so just moving them all down by 1 ensures that the whole line is visible.
Updated Fiddle

Diagonal Direction Edge Detection

Let say that a given image has an edge in some angle (not neglectable), so we use edge detection mask rotated, for example sobel operator in 45 degrees:
0 1 2
-1 0 1
-2 -1 0
or
-2 -1 0
-1 0 1
0 1 2
In this case, how we will find the magnitude of the edge?

Postscript/EPS Drawing rectangle around text

I have following postscript code
1448 2069 /moveto
(Comparator) {show newpath}
I would like to draw a rectangle around the text(Comparator) as I need to provide a hyperlink to redirect it to abbreviation page.But I am struggling to find the rest of the 2 coordinates. Would some one please advise.
Your friends are
string bool charpath
pathbbox llx lly urx ury
from the Postscript language.
so do
1448 2069 moveto
(Comparator) false charpath pathbbox newpath
will give you left-x, lower-y, right-x and upper-y on the stack. You can subtract/add some constant values to give a little space around the text and then calculate width and height instead of the right/upper values and do a rectstroke
EDIT small working sample
%!PS
/Helvetica findfont 20 scalefont setfont
20 dup moveto (Link on page1) show newpath
[ /Rect [ 20 dup moveto (Link on page1) false charpath pathbbox
2 add 4 1 roll 2 add 4 1 roll 2 sub 4 1 roll 2 sub 4 1 roll
newpath ] /Page 2 /Color [.7 0 0] /Subtype /Link /ANN pdfmark
showpage
20 dup moveto (Target on page2) show
showpage
The line 2 add 4 1 roll ... adds 2 more margin at each side. You can omit the entire line.

Masking in DCT Compression

I am trying to do image compression using DCT (Discrete Cosine Transform). Can someone please help me understand how masking affects bit per pixel in DCT? How is the bit allocation done in the masking?
PS: By masking, I mean multiplying the DCT coefficients with a matrix like the one below (element wise multiplication, not matrix multiplication).
mask = [1 1 1 1 0 0 0 0
1 1 1 0 0 0 0 0
1 1 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0]
Background on "Masking"
Compression using the DCT calculates the DCT of blocks of an image, in this case 8x8 pixels. High frequency components of an image are less important for the human perception of an image and thus can be discarded in order to save space.
The mask Matrix selects which DCT coefficients are kept and which ones get discarded in order to save space. Coefficients towards the top left corner represent low frequencies.
For more information visit Discrete Cosine Transform.
This looks like a variation of quantization matrix.
Low frequencies are in top left, high frequencies are in bottom right. Eye is more sensitive to low frequencies, so removal of high frequency coefficients will remove less important details of the image.

Resources