Hi,
i am using MosaicJ to put four pictures into one picture. It works well all the time, but only for one, after I put the 4 pictures together, and create mosaic, it gave me a whole picture which one piece of the four is moved. I tried several time. It gave one results top left moved down or down left picture moved up all the time. Could somebody tell me what is wrong with this situation and the solution? Thanks a lot. Fang -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Veeranjaneyulu TOka Sent: Dienstag, 6. November 2012 07:51 To: [hidden email] Subject: Re: Rotate an image with given angle Hi, I am facing one more issue related to this. source image size is width x height which is getting rendered on the screen. On top of the source image i am pasting a clipboard image. If i just paste clipboard image as it easily (without applying rotation), it pastes in same position as i know (x,y) and (width, height) of clipboard image where it should be pasted. In case if i apply rotation, still i get the original (x,y) position only rather than new (x,y) position which should be based on angle. But app does not have provision to give this rotated position, due to this clipboard image gets shifted. Could anyone tell me how to calculate new position when i apply rotation on clipboard image, so that it will not get shifted when it gets pasted on original image? Thanks, Veeru. On Tue, Oct 30, 2012 at 7:32 PM, Veeranjaneyulu TOka <[hidden email]>wrote: > thank you very much for the suggestion.. > > > On Tue, Oct 30, 2012 at 7:24 PM, David M Gauntt <[hidden email]> wrote: > >> In the code you wrote, the calculation of xs and ys are equivalent to >> >> xs=(x-centerX)*ca-(y-centerY)*sa+centerX; >> ys=(x-centerX)*sa+(y-centerY)*ca+centerY; >> >> which is exactly what you should use to rotate about the center if >> the source and destination image sizes were the same. In your case, >> they are not, and they should be calculated as >> >> xs=(x-dCenterX)*ca-(y-dCenterY)*sa+sCenterX; >> ys=(x-dCenterX)*sa+(y-dCenterY)*ca+sCenterY; >> >> You code is written to minimize the number of multiplications, but at >> the cost of complicating the logic, which may be why you didn't catch this. >> >> >> -- >> David M. Gauntt, Ph.D. >> Associate Professor, >> Division of Medical Physics and Engineering UAB Department of >> Radiology >> >> mailto:[hidden email] >> 205-975-3777 >> >> >> >> >> >> >> >> On 10/26/12 11:00 PM, "IMAGEJ automatic digest system" >> <[hidden email]> wrote: >> >> >Date: Fri, 26 Oct 2012 17:36:20 +0530 >> >From: Veeranjaneyulu TOka <[hidden email]> >> >Subject: Rotate an image with given angle >> > >> >Hi All, >> > >> >I am trying to rotate an image with given angle but really could >> >not manage to work this properly... Below is the piece of code i >> >have ported from ImageJ to rotate arbitrarly. >> > >> >for example here >> > >> >destWidth = 464 and destHeight = 464 >> > >> >source size is uWidth = 405 and uHeight = 227. >> > >> > >> > double centerX, centerY, angleRadians, ca, sa, tmp1, tmp2, tmp3, >> >tmp4, xs, ys, dwidth, dheight; >> > int index, x, y; >> > centerX = destWidth /2.0; >> > centerY = destHeight / 2.0; >> > >> > angleRadians = -angle/(180.0/3.14159265358979323846); >> > ca = cos(angleRadians); >> > sa = sin(angleRadians); >> > tmp1 = centerY*sa-centerX*ca; >> > tmp2 = -centerX*sa-centerY*ca; >> > dwidth = uWidth, dheight= uHeight; >> > >> > for (y=0; y<destHeight; y++) >> > { >> > index = y*destWidth*4; >> > tmp3 = tmp1 - y*sa + centerX; >> > tmp4 = tmp2 + y*ca + centerY; >> > for (x=0; x<destHeight; x++) >> > { >> > xs = x*ca + tmp3; >> > ys = x*sa + tmp4; >> > if ((xs>=-0.01) && (xs<dwidth) && (ys>=-0.01) && (ys<dheight)) >> > { >> > pbOut[index++] = pbInput[uWidth*(int)ys*4+(int)xs*4 + 0]; >> > pbOut[index++] = pbInput[uWidth*(int)ys*4+(int)xs*4 + 1]; >> > pbOut[index++] = pbInput[uWidth*(int)ys*4+(int)xs*4 + 2]; >> > pbOut[index++] = pbInput[uWidth*(int)ys*4+(int)xs*4 + 3]; >> > } >> > else >> > { >> > pbOut[index++] = 0xff; pbOut[index++] = 0xff; pbOut[index++] = >> >0xff; pbOut[index++] = 0xff; >> > } >> > } >> > >> >With the above code, the output that i get is cropping of top-right, >> >right-bottom corners. I think something problem with my output >> >buffer filling procedure though am not sure. >> > >> >Could you plz help me to figure the issue plz? I really do not have >> >clue and need your help on this. >> > >> > >> >thanks, >> >Veeru. >> > >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >> > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |