Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
midibase  
#1 Posted : Sunday, September 16, 2007 2:26:52 AM(UTC)
midibase

Rank: Member

Groups: Member
Joined: 9/16/2007(UTC)
Posts: 4

hello,
can anyone help me?
I write an application where I need to transform an Image. (See first.jpg)
I drag the blue lines to the new positions (see secound.jpg)
After I push a button I got the result from transformation very well (see third.jpg)

But my blue polygone has the wrong position (it has the old position) but I need it on the result of transformation.
I have no idea how I could solve this.

Secound question.
Is there any possibility to move the bitmap inside the BitmapViewer (Control) by set x,y coordinates or is it only possible
to use the ImageAlligement?

thangs for your help


Code Snipes:
Code:
      private void button2_Click(object sender, EventArgs e) {
            try {
                //Apply projective transform and store the result.
                GMBitmap.Bitmap.ApplyInPlace = false;

                GMBitmap.Bitmap = GMBitmap.Bitmap.Transforms.ProjectivePoints(
                    destPointX[0], destPointY[0],
                    destPointX[1], destPointY[1],
                    destPointX[2], destPointY[2],
                    destPointX[3], destPointY[3],
                    oldPointX[0], oldPointY[0],
                    oldPointX[1], oldPointY[1],
                    oldPointX[2], oldPointY[2],
                    oldPointX[3], oldPointY[3],
                    0,
                    InterpolationMode.InterpolationModeHighQuality,
                    FitMode.FitModeCircumscribed);

                GMBitmap.Bitmap.ApplyInPlace = true;

                for (int i = 0; i < 4; i++) {
                    oldPointX[i] = destPointX[i];
                    oldPointY[i] = destPointY[i];
                }
            } catch (Exception ex) {
                lbMessage.Text = ex.Message;
            }
        }





Edited by user Monday, December 17, 2007 12:29:23 PM(UTC)  | Reason: Not specified

midibase attached the following image(s):
first.jpg
secound.jpg
third.jpg
Dmitry  
#2 Posted : Tuesday, September 18, 2007 5:08:32 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hello,

It is hard to answer your question without looking through you code which manages selection and draw a polygon. It seems that you display image in the BitmapViewer, so after you apply projective transform you should calibrate polygon points taking into account that new image is diplayed in the center of control.

No, you cannot specify x and y coordinates from where bitmap is displayed inside the control.
Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
midibase  
#3 Posted : Tuesday, September 18, 2007 11:22:34 PM(UTC)
midibase

Rank: Member

Groups: Member
Joined: 9/16/2007(UTC)
Posts: 4

Yes you're right. so I post the code for you to help me
THX

File Attachment(s):
DragArea.rar (6kb) downloaded 74 time(s).
Dmitry  
#4 Posted : Tuesday, October 2, 2007 3:02:02 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hello,

Sorry for late answer.

As the size of image is changed while it is tranformed by projective points algorithm, you should move position of your polygon after transformation. You can calculate polygon offset in particular case only when source polygon is corner-aligned rectangle: (0, 0, image width, image height). In common case there is no way to calculate offset values because of implementation aspects of algorithm.

So offset will be:
  • X position: destPointX[i] -= minDestX, where minDestX - minimum x-coordinate value of destination polygon;
  • Y position: destPointY[i] -= minDestY, where minDesty - minimum y-coordinate value of destination polygon;

    Pay attention that there is a problem in DragRectangle setter - points were calcualted wrong. The correct version of setter is the following:
    Code:
     public System.Drawing.Rectangle DragRectangle {
        get { return dragRec; }
        set {
            dragRec = value;
            //'Init source points
            destPointX[0] = oldPointX[0] = dragRec.X;
            destPointY[0] = oldPointY[0] = dragRec.Y;
            //destPointX[1] = oldPointX[1] = dragRec.Width;
            destPointX[1] = oldPointX[1] = dragRec.Right;
            destPointY[1] = oldPointY[1] = dragRec.Y;
            //destPointX[2] = oldPointX[2] = dragRec.Width;
            destPointX[2] = oldPointX[2] = dragRec.Right;
            //destPointY[2] = oldPointY[2] = dragRec.Height;
            destPointY[2] = oldPointY[2] = dragRec.Bottom;
            destPointX[3] = oldPointX[3] = dragRec.X;
            //destPointY[3] = oldPointY[3] = dragRec.Height;
            destPointY[3] = oldPointY[3] = dragRec.Bottom;
        }
    }
    Click handler of "Tranform" button will be the following
    Code:
    private void button2_Click(object sender, EventArgs e) {	
        try {	
    	//Apply projective transform and store the result.
    	GMBitmap.Bitmap.ApplyInPlace = false;	
    
            int widthBefore = GMBitmap.Bitmap.Data.Width;
            int heightBefore = GMBitmap.Bitmap.Data.Height;
    
            GMBitmap.Bitmap = GMBitmap.Bitmap.Transforms.ProjectivePoints(
                destPointX[0], destPointY[0],
                destPointX[1], destPointY[1],
                destPointX[2], destPointY[2],
                destPointX[3], destPointY[3],
                oldPointX[0], oldPointY[0],
                oldPointX[1], oldPointY[1],
                oldPointX[2], oldPointY[2],
                oldPointX[3], oldPointY[3],
                0,
                InterpolationMode.InterpolationModeHighQuality,
                FitMode.FitModeCircumscribed);
    
            GMBitmap.Bitmap.ApplyInPlace = true;
    
            double minDestX = double.MaxValue;
            double minDestY = double.MaxValue;
    
            for (int i = 0; i < 4; i++)
            {
                if (minDestX > destPointX[i])
                    minDestX = destPointX[i];
                if (minDestY > destPointY[i])   
                    minDestY = destPointY[i];
            }
    
            for (int i = 0; i < 4; i++)
            {
                destPointX[i] -= minDestX;
                destPointY[i] -= minDestY;
            }
    
            for (int i = 0; i < 4; i++) {
                oldPointX[i] = destPointX[i];
                oldPointY[i] = destPointY[i];
            }
        } catch (Exception ex) {
            lbMessage.Text = ex.Message;
        }
    }
    As you develop .NET application I advise you to upgrade Graphics Mill for ActiveX to Graphics Mill for .NET. Graphics Mill for .NET is native for .NET platform and has a lot of improvements in comparison with ActiveX version. More information you can read on our site.
  • Edited by user Monday, December 17, 2007 12:29:54 PM(UTC)  | Reason: Not specified

    Sincerely yours,
    Dmitry Sevostyanov

    UserPostedImage Follow Aurigma on Twitter!
    midibase  
    #5 Posted : Wednesday, October 3, 2007 9:08:18 PM(UTC)
    midibase

    Rank: Member

    Groups: Member
    Joined: 9/16/2007(UTC)
    Posts: 4

    First of all, thanks for your help, I check it when I have time at tomorrow .

    Because upgrade Graphics Mill for ActiveX to Graphics Mill for .NET.
    I would do it but there is a big problem:
    I need the Transform-Method and it has only the Version "Graphics Mill for ActiveX"
    Or it isn't right?

    midibase
    Andrew  
    #6 Posted : Thursday, October 4, 2007 1:17:44 PM(UTC)
    Andrew

    Rank: Advanced Member

    Groups: Member, Administration
    Joined: 8/2/2003(UTC)
    Posts: 870

    Thanks: 2 times
    Was thanked: 26 time(s) in 26 post(s)
    Could you tell more detailed what exact functionality you mean? The Transforms property is just a holder for all image processing methods. The similar property is available in .NET version.

    To tell the truth I cannot remember any ActiveX version feature which is not available in .NET version. At least all features required to build the application you posted here are available there.

    If you mean arbitrary affine/projective transforms, they are available in the .NET version. Here you can read how about it (the first part of the article is the math stuff, GM-related information begins in the middle of the article):

    http://www.aurigma.com/docs/gm/Transformations.htm

    Edited by user Wednesday, October 29, 2008 12:31:02 PM(UTC)  | Reason: Not specified

    Users browsing this topic
    Forum Jump  
    You cannot post new topics in this forum.
    You cannot reply to topics in this forum.
    You cannot delete your posts in this forum.
    You cannot edit your posts in this forum.
    You cannot create polls in this forum.
    You cannot vote in polls in this forum.