Solved

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

Posted on 2010-09-19
9
347 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 125 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
Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

 
LVL 4

Assisted Solution

by:kjetilroe
kjetilroe earned 375 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 375 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

696 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