could plezz someone run this code

  • Follow


hi..

could plezz any of u run this code.. i dont have matlab now.. but i
really need to run this code now.. i want to know if there is any
error.. u can put any type of image to this code..

thanks..

IM = imread('ray image.jpg');
[p,q] = size(IM);

% create/resize image into 60-by-100
image = imresize(IM,[60 100]);			
figure, imshow(image), title('New Size')

[rows,cols] = size(image);

% create cell array all 0's
submat = zeros(rows,cols);

% divides into 3-by-5 cell array
% each cell array contain 20-by-20 matrix
submat = mat2cell(image,[20 20 20],[20 20 20 20 20]);
[20,20] = size(submat);

for i = 1 : 20 : rows
    for j = 1 : 20 : cols
        submat(i,j) = image(i,j);
         
        disp(submat{i,j})
    end
end

figure,imshow(submat), title('New Submatrices')
submat = zeros(rows,cols);
0
Reply jullgunit (59) 1/18/2005 7:31:44 AM

Hi,

I see that you are still working on your project :

I can't run this one for you because I have any tooolbox.

But I saw some wrong things :

> % create cell array all 0's
> submat = zeros(rows,cols);

That's wrong. It's creating an array not a cell array
I think you should replace submat by mycellarray.
It could be a good start to avoid the confusion that you still make
between both. TO preallocate you cell array try this :

[mycellarray{1:3,1:5}]=deal(zeros(20,20))

this create a 3x5 cell array composed of fifteen 20x20 zeros matrix.

Looking at your code I wonder why don't you use an easier code :

[IM,map,alpha] = imread('essai.jpg','jpg');

figure('Name','Original jpeg image');
imagesc(IM);
axis image
 
[mycellarray{1:3,1:5}] = deal(zeros(20,20));

figure('Name','Broken Image');
k=1;
for i = 1 : 5
    for j = 1 : 3
        
    ind1=(i-1)*20+1:i*20;
    ind2=(j-1)*20+1:j*20;
        
    mycellarray{i,j} = IM(ind1,ind2);
 
    subplot(5,3,k);
    imagesc(mycellarray{i,j});

    k=k+1;
        
    end
end

Your image is broken into sub one contained in a cell array
mycellarray

Hope It Helps
J�r�me.
0
Reply dutmatlab (3796) 1/18/2005 8:52:22 AM


J�r�me wrote:
>
>
> Hi,
>
> I see that you are still working on your project :
>
> I can't run this one for you because I have any tooolbox.
>
> But I saw some wrong things :
>
>> % create cell array all 0's
>> submat = zeros(rows,cols);
>
> That's wrong. It's creating an array not a cell array
> I think you should replace submat by mycellarray.
> It could be a good start to avoid the confusion that you still make
> between both. TO preallocate you cell array try this :
>
> [mycellarray{1:3,1:5}]=deal(zeros(20,20))
>
> this create a 3x5 cell array composed of fifteen 20x20 zeros
> matrix.
>
> Looking at your code I wonder why don't you use an easier code :
>
> [IM,map,alpha] = imread('essai.jpg','jpg');
>
> figure('Name','Original jpeg image');
> imagesc(IM);
> axis image
>
> [mycellarray{1:3,1:5}] = deal(zeros(20,20));
>
> figure('Name','Broken Image');
> k=1;
> for i = 1 : 5
> for j = 1 : 3
>
> ind1=(i-1)*20+1:i*20;
> ind2=(j-1)*20+1:j*20;
>
> mycellarray{i,j} = IM(ind1,ind2);
>
> subplot(5,3,k);
> imagesc(mycellarray{i,j});
>
> k=k+1;
>
> end
> end
>
> Your image is broken into sub one contained in a cell array
> mycellarray
>
> Hope It Helps
> J�r�me.

hi

thanks jerome..
i'll try to run ur code later.. at home..
bye..

julie
0
Reply jullgunit (59) 1/18/2005 9:23:48 AM

julie wrote:
>
>
> J�r�me wrote:
>>
>>
>> Hi,
>>
>> I see that you are still working on your project :
>>
>> I can't run this one for you because I have any tooolbox.
>>
>> But I saw some wrong things :
>>
>>> % create cell array all 0's
>>> submat = zeros(rows,cols);
>>
>> That's wrong. It's creating an array not a cell array
>> I think you should replace submat by mycellarray.
>> It could be a good start to avoid the confusion that you still
> make
>> between both. TO preallocate you cell array try this :
>>
>> [mycellarray{1:3,1:5}]=deal(zeros(20,20))
>>
>> this create a 3x5 cell array composed of fifteen 20x20 zeros
>> matrix.
>>
>> Looking at your code I wonder why don't you use an easier code
:
>>
>> [IM,map,alpha] = imread('essai.jpg','jpg');
>>
>> figure('Name','Original jpeg image');
>> imagesc(IM);
>> axis image
>>
>> [mycellarray{1:3,1:5}] = deal(zeros(20,20));
>>
>> figure('Name','Broken Image');
>> k=1;
>> for i = 1 : 5
>> for j = 1 : 3
>>
>> ind1=(i-1)*20+1:i*20;
>> ind2=(j-1)*20+1:j*20;
>>
>> mycellarray{i,j} = IM(ind1,ind2);
>>
>> subplot(5,3,k);
>> imagesc(mycellarray{i,j});
>>
>> k=k+1;
>>
>> end
>> end
>>
>> Your image is broken into sub one contained in a cell array
>> mycellarray
>>
>> Hope It Helps
>> J�r�me.

hi..

i've run ur code.. but i'm still not really sure about some functions
in that code.. after i compiled it, image has been broken into 15
cell array size 20x20.. but not in the grayscale type.. should i put
colormap gray

subplot(5,3,k);
imagesc(mycellarray{i,j});
colormap gray;
k = k+1;

one more thing, i'm not understand this statement..

ind1=(i-1)*20+1:i*20;
ind2=(j-1)*20+1:j*20;

thanks 4 ur help.. and i'm still working on the same project using
mat2cell.

thanks
julie
0
Reply jullgunit (59) 1/19/2005 7:20:59 AM

Hi,

just add "colormap gray" after the figure creation. Because it is
applied to figure, you don't have to set it for each subplot.

The indices ind1 & ind2 are just indices of your IM matrix.

ind1 corresponds to the rows indice of IM, ind2 to its columns
indices

i=1 => ind1= 1 to 20 (IM rows 1 to 20)
i=2 => ind1= 21 to 40 (IM rows 21 to 40)
....
i=5 => ind1= 21 to 40 (IM rows 81 to 100)

j=1 => ind2= 1 to 20 (IM columns 1 to 20)
....
j=3 => ind2= 41 to 60 (IM columns 41 to 60)

so each time the code takes a 20x20 elements of IM.

J�r�me.
0
Reply dutmatlab (3796) 1/19/2005 10:43:38 AM

4 Replies
22 Views

(page loaded in 0.189 seconds)

Similiar Articles:













7/21/2012 11:21:31 PM


Reply: