# How to?

This topic is 4667 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, currently i am working on a project, an Image Processing project, i am using C Sharp language.. i dont know what the process or the technique is called, but i want to do the following: i have an image, the border of the image has a shape similar to a trapezoid. imagine i am taking a perspective picture of a rectangular plate, depending on the angle i am taking the image with, i will have a different shape every time, i want to take this shape and transform it to a perfect rectangle, with maintaining the information inside the image (binary colors: black and white). i hope i gave the correct image of what i want. what procedure should i use? 10x in advance

##### Share on other sites
Well, the simplest approach is to simply take each line of pixels and scale it up to the same width as the widest row. That gives you a perfect rectangle. If your aim is to recreate then image on the 'plate,' then you'll need to apply some vertical stretch as well.

##### Share on other sites
is there any faster way?

i think it will take time to take each line of pixels and scale it up to the same width as the widest row, specially if the picture was big in size?

##### Share on other sites
Well, if you're willing to create an image that is smaller than the widest row, then you can use a 'shading' approach.

You specify your desired resulting image width/height in pixels. Then, loop over each pixel, and 'sample' the original trapezeoid.

You'll need a function to convert perfect-rectangle coordinates to trapeseoid-coordinates; a simple interpolation approach will give you reasonable results, but you may want to build some kind of perspective correction into it.

The simple interpolation approach is to take the original coordinates as fractions of the target image dimensions (e.g. pixel (20, 20) in a 400x400 image gives you (0.05, 0.05)). Take the four vertices of the trapezeoid in the source image and use these coordinates to interpolate between them.

If you need really high performance, you might be able to adapt this technique to the GPU, though if the images are too large then you might run into problems.

##### Share on other sites
If I am following your question correctly, you have an image taken in perspective view and you want to transform it into an orthogonal view? If that is the case, applying the inverse perspective transformation function to the pixel location of the image should work. (Hard part is knowing what the various perspective parameters are for the image, but it is solvable given that you have some of the information present.) Then any "blank" pixels would have to get filled in based on an average neighbor search.

##### Share on other sites
Quote:
 Original post by absoIf I am following your question correctly, you have an image taken in perspective view and you want to transform it into an orthogonal view? If that is the case, applying the inverse perspective transformation function to the pixel location of the image should work. (Hard part is knowing what the various perspective parameters are for the image, but it is solvable given that you have some of the information present.) Then any "blank" pixels would have to get filled in based on an average neighbor search.

i dont have any information about the coordinates of the image, i have it as a bmp

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 13
• 48
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632965
• Total Posts
3009545
• ### Who's Online (See full list)

There are no registered users currently online

×