Ask an expert. Trust the answer.

Your academic and career questions answered by verified experts

display image between four corner points Matlab

Date: 2022-11-17 15:02:35

Suppose I have 4 corner points : (x1, y1) ; (x2, y2) ;(x3, y3) ; (x4, y4) and a rectangular image size (m,n) How do I display the image such that the image when shown has its corners at the four mentioned points. In other words, four corners can control the angle at which the image is rotated (bear in mind the image edges might not be parallel) Thanks! 

Expert Answer:

s: 

You need to warp the image for a generalized solution. You can do it as follows:

First, Read the image. 

 

 img=imread('cameraman.tif');
if size(img,3)==3
   img=rgb2gray(img);

Specify the set of transformed points (in your case, (x1,y1) ... (x4,y4)), they are fixedPoints

 

 movingPoints=[1 1;256 1; 256 256; 1 256] %(x,y) coordinate
fixedPoints=[25 25;250 12;255 200;30 180];

Then, estimate the transformation. I choose projective transformation. You can choose affine as well. 

TFORM = fitgeotrans(movingPoints,fixedPoints,'projective');

Since, you want the image to go to the specified corners, you have to specify the output view. It can be done by constructing a reference 2-D image as follows.

R=imref2d(size(img),[1 size(img,2)],[1 size(img,1)]);

Finally, warp the image.

imgTransformed=imwarp(imread('cameraman.tif'),R,TFORM,'OutputView',R);

Show the image.

imshow(imgTransformed,[]); 
You should have the corners of your image at the specified points and the box which contains the image will be of the size of the original image.

Why Matlabhelpers ?

Looking for reliable MATLAB assignment help? Our expert MATLAB tutors deliver high-quality, easy-to-understand solutions tailored to your academic needs. Whether you're studying at Monash University, the University of Sydney, UNSW, or the University of Melbourne, we provide trusted MATLAB assistance to help you excel. Contact us today for the best MATLAB solutions online and achieve academic success!

MATLAB Assignment Help Services

Personalized Tutoring: Get one-on-one guidance from our MATLAB experts. Whether you're tackling basic concepts or advanced algorithms, we provide clear, step-by-step explanations to help you master MATLAB with confidence.

Assignment Assistance: Struggling with tight deadlines or complex assignments? Our team offers end-to-end support, from problem analysis to code development and debugging, ensuring your assignments meet the highest academic standards.

Project Development: Need expert help with your MATLAB research project? We assist in designing and implementing robust solutions, covering project planning, data collection, coding, simulation, and result analysis.

Coursework Support: Enhance your understanding of MATLAB with our comprehensive coursework assistance. We help you grasp lecture concepts, complete lab exercises, and prepare effectively for exams.

Thesis and Dissertation Guidance: Incorporate MATLAB seamlessly into your thesis or dissertation. Our experts provide support for data analysis, modeling, and simulation, ensuring your research is methodologically sound and impactful.

Contact us on WhatsApp for MATLAB help

Contact us on Telegram for MATLAB solutions