Solved

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

Posted on 2010-09-19
9
331 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
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 13

Assisted Solution

by:SameerJagdale
SameerJagdale earned 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
whats your container for image?
0
 
LVL 4

Assisted Solution

by:kjetilroe
kjetilroe earned 375 total points
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now