Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
matrix in a matrix

Subject: matrix in a matrix

From: th

Date: 14 May, 2010 10:58:05

Message: 1 of 9

hallo there.

I want to put a matrix that is 128X128 in a matrix that is 512X512 ( ones(512) ).

what I want to do is to have the white image and above to put the second image ( a letter, A for example).

I cant multiply cause they dont have the same dimensions.


any ideas??




thanks in advance

Subject: matrix in a matrix

From: us

Date: 14 May, 2010 11:08:04

Message: 2 of 9

"th " <THOMITSU@YAHOO.COM> wrote in message <hsjabs$bbc$1@fred.mathworks.com>...
> hallo there.
>
> I want to put a matrix that is 128X128 in a matrix that is 512X512 ( ones(512) ).
>
> what I want to do is to have the white image and above to put the second image ( a letter, A for example).
>
> I cant multiply cause they dont have the same dimensions.
>
>
> any ideas??
>
>
>
>
> thanks in advance

one of the many solutions

     sm=magic(2);
     bm=zeros(6,'double');
     bm(3:4,3:4)=sm
%{
% bm =
     0 0 0 0 0 0
     0 0 0 0 0 0
     0 0 1 3 0 0
     0 0 4 2 0 0
     0 0 0 0 0 0
     0 0 0 0 0 0
%}

us

Subject: matrix in a matrix

From: th

Date: 14 May, 2010 11:17:04

Message: 3 of 9

"th " <THOMITSU@YAHOO.COM> wrote in message <hsjabs$bbc$1@fred.mathworks.com>...
> hallo there.
>
> I want to put a matrix that is 128X128 in a matrix that is 512X512 ( ones(512) ).
>
> what I want to do is to have the white image and above to put the second image ( a letter, A for example).



that wasnt exactly what i meant..

I1=imread('Aneg.tif'); % this is the image with the letter
I1=double(I1);
I1=1-I1; % i make it with a white background and the letter is black

I1=imresize(I1,0.25); % I resize it

figure(1); imshow(I1,[]);

I2=ones(512) ;

and now what i want to do is to put I1 on I2. i want to have a smaller image in a bigger image, so I can have my small letter in a big white background

cant multiply though...

ideas??

Subject: matrix in a matrix

From: us

Date: 14 May, 2010 11:29:05

Message: 4 of 9

"th " <THOMITSU@YAHOO.COM> wrote in message <hsjbfg$n2e$1@fred.mathworks.com>...
> "th " <THOMITSU@YAHOO.COM> wrote in message <hsjabs$bbc$1@fred.mathworks.com>...
> > hallo there.
> >
> > I want to put a matrix that is 128X128 in a matrix that is 512X512 ( ones(512) ).
> >
> > what I want to do is to have the white image and above to put the second image ( a letter, A for example).
>
>
>
> that wasnt exactly what i meant..
>
> I1=imread('Aneg.tif'); % this is the image with the letter
> I1=double(I1);
> I1=1-I1; % i make it with a white background and the letter is black
>
> I1=imresize(I1,0.25); % I resize it
>
> figure(1); imshow(I1,[]);
>
> I2=ones(512) ;
>
> and now what i want to do is to put I1 on I2. i want to have a smaller image in a bigger image, so I can have my small letter in a big white background
>
> cant multiply though...
>
> ideas??

why should the solution shown above not work(?)...

us

Subject: matrix in a matrix

From: Sean

Date: 14 May, 2010 11:39:05

Message: 5 of 9

"th " <THOMITSU@YAHOO.COM> wrote in message <hsjbfg$n2e$1@fred.mathworks.com>...
> "th " <THOMITSU@YAHOO.COM> wrote in message <hsjabs$bbc$1@fred.mathworks.com>...
> > hallo there.
> >
> > I want to put a matrix that is 128X128 in a matrix that is 512X512 ( ones(512) ).
> >
> > what I want to do is to have the white image and above to put the second image ( a letter, A for example).
>
>
>
> that wasnt exactly what i meant..
>
> I1=imread('Aneg.tif'); % this is the image with the letter
> I1=double(I1);
> I1=1-I1; % i make it with a white background and the letter is black
>
> I1=imresize(I1,0.25); % I resize it
>
> figure(1); imshow(I1,[]);
>
> I2=ones(512) ;
>
> and now what i want to do is to put I1 on I2. i want to have a smaller image in a bigger image, so I can have my small letter in a big white background
>
> cant multiply though...
>
> ideas??

What us said will work, you're just going to have to think about it a little.
Another way:
>>A= magic(128);
>>B = padarray(A,[floor((512-128)/2) floor((512-128)/2)], 1);

Subject: matrix in a matrix

From: th

Date: 14 May, 2010 12:03:05

Message: 6 of 9

it doesnt work cause i dont want a magic matrix.i want my matrix. its an image (black letter A in a white background) having a size of 128X128.

I want to put this small letter in a big white background (512X512)

Subject: matrix in a matrix

From: th

Date: 14 May, 2010 12:06:04

Message: 7 of 9

it doesnt work cause i dont want a magic matrix.i want my matrix. its an image (black letter A in a white background) having a size of 128X128.

I want to put this small letter in a big white background (512X512)

Subject: matrix in a matrix

From: Sean

Date: 14 May, 2010 12:13:06

Message: 8 of 9

"th " <THOMITSU@YAHOO.COM> wrote in message <hsje5p$f2c$1@fred.mathworks.com>...
> it doesnt work cause i dont want a magic matrix.i want my matrix. its an image (black letter A in a white background) having a size of 128X128.
>
> I want to put this small letter in a big white background (512X512)

Well let's see; how hard is it to change your choice of matrices? You could use:
>>A = magic(128)
>>A = rand(128)
>>A = zeros(128)
>>A = ones(128)
>>A = your_matrix
>>A = pascal(128)

One of those 6 probably should satisfy your needs.

Then do exactly what us or I said. Oh, I forgot, you might also have to change a number or something too. We provided the logic; now you have to make it work for your application.

Subject: matrix in a matrix

From: Steven Lord

Date: 14 May, 2010 13:18:23

Message: 9 of 9


"th " <THOMITSU@YAHOO.COM> wrote in message
news:hsje5p$f2c$1@fred.mathworks.com...
> it doesnt work cause i dont want a magic matrix.i want my matrix. its an
> image (black letter A in a white background) having a size of 128X128.
>
> I want to put this small letter in a big white background (512X512)

And us posted _an example_ of the technique you need to use. All you need
to do is adapt it slightly to use your image instead of the _sample_ data us
used.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us