vendredi 14 novembre 2014

Resizing and Repeating an Image


Vote count:

0




I've been doing pretty well with images this week, but I've run into a problem. I am trying to take an image and make it 1/4th of it's original size, then have it repeated as a 2x2 matrix. Kind-of like this:



Given an input image:
---------------------
| |
| |
| IMG |
| |
| |
---------------------

Firstly, shrink it to 1/4 of its original size:
-----------
| img |
| |
|---------|

Then concatenate it into a "2x2 array" of the shrunken image:
---------------------
| img | img |
| | |
|---------|---------|
| img | img |
| | |
---------------------


What I am struggling with is the fact that I do not know how to make it into a 2x2 array. Any suggestions? This isn't actually HW this time :) It's for studying purposes. Here's what I've tried so far:



function[newImg] = immultiply(picture)

Image = imread(picture); %// Reads in the picture
[r, c, l] = size(Image); %// Finds the images rows, columns and layers
rows = round(r ./ 2); %// Divides up the rows
columns = round(c ./ 2); %// Divides up the columns

newImg = cat(3,rows,columns,3); %// Creates my image, but just gives me a blank thing
imshow(newImg)


end


I will update as I work on it further. Thanks!



asked 53 secs ago







Resizing and Repeating an Image

Aucun commentaire:

Enregistrer un commentaire