Click here to Skip to main content
15,914,160 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: logger performance Pin
Roland Pibinger15-Jan-06 4:00
Roland Pibinger15-Jan-06 4:00 
AnswerRe: logger performance Pin
Chintoo72315-Jan-06 4:38
Chintoo72315-Jan-06 4:38 
GeneralRe: logger performance Pin
Roland Pibinger15-Jan-06 5:55
Roland Pibinger15-Jan-06 5:55 
GeneralRe: logger performance Pin
Chintoo72315-Jan-06 15:38
Chintoo72315-Jan-06 15:38 
AnswerRe: logger performance Pin
cmk15-Jan-06 18:46
cmk15-Jan-06 18:46 
AnswerRe: logger performance Pin
kakan15-Jan-06 20:08
professionalkakan15-Jan-06 20:08 
QuestionSimulating mouse clicks on SysDateTimePick32 control Pin
Still learning how to code14-Jan-06 21:40
Still learning how to code14-Jan-06 21:40 
AnswerRe: Simulating mouse clicks on SysDateTimePick32 control Pin
Gary R. Wheeler15-Jan-06 4:23
Gary R. Wheeler15-Jan-06 4:23 
GeneralRe: Simulating mouse clicks on SysDateTimePick32 control Pin
Still learning how to code15-Jan-06 22:00
Still learning how to code15-Jan-06 22:00 
GeneralRe: Simulating mouse clicks on SysDateTimePick32 control Pin
Gary R. Wheeler17-Jan-06 16:11
Gary R. Wheeler17-Jan-06 16:11 
Questionhow to draw table? Pin
Ali Tavakol14-Jan-06 21:13
Ali Tavakol14-Jan-06 21:13 
AnswerRe: how to draw table? Pin
includeh1015-Jan-06 3:54
includeh1015-Jan-06 3:54 
GeneralRe: how to draw table? Pin
Ali Tavakol15-Jan-06 20:14
Ali Tavakol15-Jan-06 20:14 
Questionvariable, a simple suggestion to C/C++ beginner Pin
includeh1014-Jan-06 17:13
includeh1014-Jan-06 17:13 
AnswerRe: variable, a simple suggestion to C/C++ beginner Pin
El Corazon14-Jan-06 17:49
El Corazon14-Jan-06 17:49 
GeneralRe: variable, a simple suggestion to C/C++ beginner Pin
Stephen Hewitt14-Jan-06 18:03
Stephen Hewitt14-Jan-06 18:03 
GeneralRe: variable, a simple suggestion to C/C++ beginner Pin
El Corazon14-Jan-06 18:39
El Corazon14-Jan-06 18:39 
GeneralRe: variable, a simple suggestion to C/C++ beginner Pin
Shraddhan22-Jan-06 23:34
Shraddhan22-Jan-06 23:34 
Questionstructure representing file Pin
John Simon14-Jan-06 14:50
John Simon14-Jan-06 14:50 
AnswerRe: structure representing file Pin
El Corazon14-Jan-06 15:04
El Corazon14-Jan-06 15:04 
QuestionHard maths problem Pin
Christian Graus14-Jan-06 12:41
protectorChristian Graus14-Jan-06 12:41 
I've inherited an image processing task which I didn't initially write, but which I need to modify - I need to change an input parameter according to the position within the input image. Naturally, the code works by iterating over the destination image, but now I need to change it to iterate over the source image, so I can work out this parameter as I go. The parameter is called sourceFOVRads ( for reference in the code ). The trouble is, I can't work out how to reverse the code so that it iterates over the source instead of destination image. Of course, I know how to iterate over an image using polar co-ordinates, but I think the transform needs to be completely rewritten, I don't see how to reverse the Atan2 calls to get the input parameters.

for(int j=0;j<output.height;j++)
{
for(int="" i="0;i<output.Width;i++)
" {
="" double="" x="2" *="" (double)output.width="" -="" 1;="" -1="" to="" 1

="" y="2" j="" (double)output.height="" calculate="" phi="" and="" theta=""
="" latitude="y*Math.PI/2;" -pi="" 2="" <="y" pi="" longitude="x*Math.PI;"

="" p="" is="" the="" vector="" from="" camera="" position="" into="" scene="" p.x="Math.Cos(latitude)*" math.sin(longitude);
="" p.y="Math.Cos(latitude)*" math.cos(longitude);
="" p.z="Math.Sin(latitude);

" fisheye="" polar="" coordinates
="" r="pixelRadius*phi" sourcefovrads;
="" determine="" coordinate="" in="" source="" image
="" u="Convert.ToInt32(fishCentre.X" +="" r*math.cos(theta));
="" if(u="" 0="" ||="">=source.Width)
continue;
v=Convert.ToInt32(fishCentre.Y - r*Math.Sin(theta));
if(v < 0 || v>=source.Height)
continue;

pOut[(outputStride*j)+(i*3)]=(Byte)(int)pSrc[(sourceStride*v)+(u*3)];
pOut[(outputStride*j)+(i*3)+ 1]=(Byte)(int)pSrc[(sourceStride*v)+(u*3)+ 1];
pOut[(outputStride*j)+(i*3)+ 2]=(Byte)(int)pSrc[(sourceStride*v)+(u*3)+ 2];

As I said, I can do the basic stuff, like so:

for (double t = 0; t < 2 * Math.PI; t += .01)
{
for (int radius = 0; radius < pixelRadius; ++radius)
{
int xSrc = (int)(radius * Math.Cos(t)) + fishCentre.X;
int x = 2 * (xSrc/source.Width) - 1;
int ySrc = (int)(radius * Math.Sin(t)) + fishCentre.Y;
int y = 2 * (xSrc/source.Height) - 1;

pOut[(int)(x*3 + y * sourceStride)] = pSrc[(int)(x*3 + y * sourceStride)];
pOut[(int)(x*3 + 1 + y * sourceStride)] = pSrc[(int)(x*3 + 1 + y * sourceStride)];
pOut[(int)(x*3 + 2 + y * sourceStride)] = pSrc[(int)(x*3 + 2 + y * sourceStride)];
}
}

This code uses polar co-ordinates to copy just the circle of the image that we're interested in, without any transform. It steps over the theta far too quickly mostly so I can quickly see the results of my code Smile | :)

However, in this block:

theta=Math.Atan2(p.z,p.x);
phi=Math.Atan2(Math.Sqrt(p.x*p.x+p.z*p.z),p.y);
r=pixelRadius*phi / sourceFOVRads;

I don't know where to start. I have the pixel radius and r, and as I have my source radius, I can calculate which sourceFOVRads value to use, so I can work out phi, easily. But, I obviously cannot derive the values for p.x, p.y and p.z from this value, and I'm not sure how else to go about it. Any help on this will be greatly appreciated, because I am really stuck.

BTW, the code is C#, I posted it here for visibility.

Christian Graus - Microsoft MVP - C++
AnswerRe: Hard maths problem Pin
Sean Cundiff14-Jan-06 14:25
Sean Cundiff14-Jan-06 14:25 
GeneralRe: Hard maths problem Pin
Christian Graus14-Jan-06 19:56
protectorChristian Graus14-Jan-06 19:56 
AnswerRe: Hard maths problem Pin
Stephen Hewitt14-Jan-06 14:35
Stephen Hewitt14-Jan-06 14:35 
GeneralRe: Hard maths problem Pin
Christian Graus14-Jan-06 19:52
protectorChristian Graus14-Jan-06 19:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.