Solved

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

Posted on 2010-09-19
9
338 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
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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 85

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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)…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

809 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