MATLAB: For function with impixel

for functionImage Processing Toolboximpixelrange for function

I have been using the following code to create a matrix of a range of pixel RGB values. The code works fine if y and x are set to start at 1 however, if I ask it to start at 2 or anywhere else it gives me a load of zero values for x = y = 1 even though I didn't ask for them.
What I would like is impixel to make a matrix just of the RGB within the range. How do I make impixel work in the range set? Or what I thought was set. Thanks.
A = imread('image.jpg');
for y = 2:10;
for x = 2:10;
B(:,x,y) = impixel(A,x,y);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Comment added 08.50am 01/11/2011
Thanks for the replies so far.
What I would like to do is used regionprops(C,'boundarybox') of an image, using the box as my range of pixels. Then with the above code obtain the RGB values for just the box region. The box would set my x and y values. The image is 480 by 720.
The boundary that I want matlab to pick up is a card board printed image of a black cross, on white paper. The reason for this is so I can find out the ideal range of values of the card (my reference). Once I have my reference I can record moving the camera and compare how the quality changes in a mathematical way.
I've purposely simplified the variables in the above code to make my problem clear. X is the amount of pixels along the X direction, Y is the amount of pixel along the Y direction.
Hope this makes it clearer.

Best Answer

You do not initialize B, so when you assign in to it starting at (:,2,2) then (:,1,:) and (:,:,1) are going to have the default value 0.
Perhaps you want
B(:,x-1,y-1) = impixel(A,x,y);