-2

I was given some data that I would like to convert to a pixelized image. From what I understood, the original data was plotted by using the function 'rectangle' in Matlab. However, a 2D image is now required.

This data has four columns and ~1000 rows. The first to fourth columns correspond to //

Matrice = [Left corner X, Left corner Y, Width, Height]

So for instance, the first row is [2,3,5,6], meaning that there is a rectangle with lower left corner position of (2,3), width of 5 and height of 6.

I've been trying to find a method to use this data and turn it into an image of any dimensions with any pixel size. Either there is a function out there that I've been missing, or I am missing an easy method. Everything I've tried so far is overly complicated.

Vinci
  • 3
  • 2
  • 1
    Please clarify what you are exactly looking for and what you solved already. Plotting a rectangle? Scaling the image? Export a plot? See [ask]. Please remove information that is not essential. What have you tried so far? – m7913d Sep 07 '17 at 07:01

1 Answers1

0

This will create filled black rectangles at the specified positions. Experiment with the optional arguments of rectangle to get different visuals. Assuming your matrix is named A:

figure
for ii = 1:size(A, 1)
    rectangle('Position', A[ii, :], 'FaceColor', 'k')
    hold on
end
hold off
axis equal  % makes the pixels square
buzjwa
  • 2,632
  • 2
  • 24
  • 37