?
Solved

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

Posted on 2010-09-19
9
Medium Priority
?
351 Views
Last Modified: 2012-08-14
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?
0
Comment
Question by:6rant6
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 13

Assisted Solution

by:SameerJagdale
SameerJagdale earned 500 total points
ID: 33713949
if you are using a picturebox / image control they have an option to Fill, Uniform, UniformToFill, Strech, etc. does this not solve your purpose?
0
 
LVL 1

Author Comment

by:6rant6
ID: 33714150
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.
0
 
LVL 13

Expert Comment

by:SameerJagdale
ID: 33714323
whats your container for image?
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 4

Assisted Solution

by:kjetilroe
kjetilroe earned 1500 total points
ID: 33714659
From what you want to achive, it is possible to extract a non rectangular portion of an image, and create anoter image from it. I suggest you investigate the use of masked bitmap.

After doing some investigation, seems like the best way is to use BitBlt for this. See this article about how to do this:

http://msdn.microsoft.com/en-us/library/dd756625(VS.85).aspx

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 33715866
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!...   =)
0
 
LVL 1

Author Comment

by:6rant6
ID: 33717076
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
0
 
LVL 1

Author Comment

by:6rant6
ID: 33717104
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.
0
 
LVL 4

Accepted Solution

by:
kjetilroe earned 1500 total points
ID: 33717295
The picturebox does not seem to cover your need. Maybe you should take a look at these two articles done in C#:

http://www.codeproject.com/KB/GDI-plus/MomentsTracking.aspx

http://www.codeproject.com/KB/GDI-plus/ImageMultification.aspx

No matter what, I think you need to program some GDI+ to do what you are asking about.
0
 
LVL 1

Author Closing Comment

by:6rant6
ID: 33739412
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,.
0

Featured Post

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question