Link to home
Start Free TrialLog in
Avatar of 6rant6
6rant6Flag for United States of America

asked on

How do I change a non-rectangular portion of an image into an image?

This is a problem for image manipulation using visual studio.

I have a photo of a part.  The part is rectangular, but the image of the part may not be rectangular. It will be quadrilateral of course.

I want to create an image by identifying the four corners of the object, clipping to that area and putting that into a rectangular bit map. Another way to think of it is to skew the original image so the part is rectangular and then crop there.

I know that i can do a pixel by pixel creation of the new image, but I'm guessing that's computationally slow.

Is there a way to skew, distort, or translate an object within .net to achieve the new rectangular image?
SOLUTION
Avatar of SameerJagdale
SameerJagdale
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 6rant6

ASKER

I am not aware of any way that you can set the image to anything that is not rectangular.  So I don't see how it helps.  

I think by definition bitmap is rectangular.
whats your container for image?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Tomlinson
Can you post the source image?

Is the non-rectangular area supposed to be detected automatically and then rotated?
...or are you looking for some way to allow the user to select the image visually at run-time and then have that rotated?

If "auto" rotated, will it always be in the same spot with the same size?
...does this need to be done with more than one image?

Details, details, details, please!...   =)
Avatar of 6rant6

ASKER

An example in pictures:
Step 1: the original picture
Step 2: the user picks the corners visually
Step 3: The selected portion is all that matters
Step 4: The selected portion is "squared up" [This is where I need help]
Step 5: the new image is stored at the same size as the original

I did this example in a photo editing program. This is not an option for this application. The pictures are taken manually, so each one is a little different. But all objects are rectangular.
filmstrip.png
Avatar of 6rant6

ASKER

The control I'm using is a picturebox; if you have another solution that uses a different control, that's fine.

The initial photos will by jpgs.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 6rant6

ASKER

I'm sure there's a reasonable way to do what I want without using GDI, but for now, I'll have to work around,.