Circshift error

  • Follow


I am currently working on 3D reconstruction of multiple images from a optical bioimaging technique called Full-field Optical Coherence Tomography. I am currently trying to reconstruct a 3D model from 25 images (frame1, frame2, .... , frame25)

Hence I am currently modifying Doug Hull's 3D Solid Reconstruction of Planar Slices matlab code as his code reconstructs only two planar slices, one base_image and the move_image.

I am having a problem at one area involving the circshift function. 

Basically i have read in the images as follows;

for i = startFrame:endFrame

base_filename = 'frame1.tif';                                     %Filename of nonmoving image
move_filename = [filebase, num2str(i, '%3d'), '.tif'];
base_image(:,:,:) = imread(base_filename);
move_image(:,:,:,i) = imread(move_filename);    %Filename of image that will move to the base image

end


The problem now occurs here. The error message is "Invalid Shift Type: Shift must be a finite, nonsparse, real integer vector. "

for i = startFrame:endFrame

move_image(:,:,i)= circshift(move_image(:,:,i), [move_delta_rows(:,:,i), move_delta_cols(:,:,i)]);
move_binary_mask(:,:,i)= circshift(move_binary_mask(:,:,i), [move_delta_rows(:,:,i),
move_delta_cols(:,:,i)]);

end;

For the base image, it seems to work fine. 

base_image = circshift(base_image , [base_delta_rows, base_delta_cols]);
base_binary_mask = circshift(base_binary_mask, [base_delta_rows, base_delta_cols]);

Thank you for any help rendered.

Anitha
0
Reply Anitha 12/15/2010 6:50:13 AM

On 15/12/10 12:50 AM, Anitha wrote:

> The problem now occurs here. The error message is "Invalid Shift Type:
> Shift must be a finite, nonsparse, real integer vector. "
>
> for i = startFrame:endFrame
>
> move_image(:,:,i)= circshift(move_image(:,:,i), [move_delta_rows(:,:,i), move_delta_cols(:,:,i)]);

Check your code again. Is

[move_delta_rows(:,:,i), move_delta_cols(:,:,i)]

finite, non-sparse, real, integer-valued, and a _vector_ ?
0
Reply Walter 12/15/2010 7:09:59 AM


Glad to see this code is still useful.  I agree with the above suggestion.  If you are still having problems, please contact me.

Doug
0
Reply Doug 12/15/2010 4:36:20 PM

I am still not sure how I can change it to a vector and non-sparse. It is a 1 by 1 by 25 double array now. So is there any other function I should or could use in place of circshift then? Sorry for the trouble, as I am still quite new to Matlab. 


for i = startFrame:endFrame

move_bw_plane_of_interest(:,:,i) = im2bw(move_image(:,:,i), graythresh(move_image(:,:,i)));
move_plane_of_interest_segmented(:,:,i) = bwmorph(move_bw_plane_of_interest(:,:,i), 'open');
move_binary_mask(:,:,i) = imfill(move_plane_of_interest_segmented(:,:,i), 'holes');

move_properties(:,:,i) = regionprops(real(move_binary_mask(:,:,i)),'all');
move_centroid_row(:,:,i) = round(move_properties(:,:,i).Centroid(2));
move_centroid_col(:,:,i) = round(move_properties(:,:,i).Centroid(1));

move_image(move_centroid_row(:,:,i), move_centroid_col(:,:,i), 1) = 255;
move_image(move_centroid_row(:,:,i), move_centroid_col(:,:,i), 2) = 255;
move_image(move_centroid_row(:,:,i), move_centroid_col(:,:,i), 3) = 255;

move_image(:,:,i) = make_odd_by_odd1(move_image(i));
move_binary_mask(:,:,i) = make_odd_by_odd1(move_binary_mask(i));
[move_num_rows(:,:,i), move_num_cols(:,:,i), move_num_layers(:,:,i)] = size(move_image(:,:,i));

move_goal_row(:,:,i) = ((move_num_rows(:,:,i) - 1) / 2) + 1;
move_goal_col(:,:,i) = ((move_num_cols(:,:,i) - 1) / 2) + 1;

move_delta_rows(:,:,i) = move_goal_row(:,:,i) - move_centroid_row(:,:,i);
move_delta_cols(:,:,i) = move_goal_col(:,:,i) - move_centroid_col(:,:,i);

move_image(:,:,i)= circshift(move_image(:,:,i), ([move_delta_rows(:,:,i), move_delta_cols(:,:,i)]));
move_binary_mask(:,:,i)= circshift(move_binary_mask(:,:,i),[move_delta_rows(:,:,i),
move_delta_cols(:,:,i)]);

end;



"Doug Hull" <hull@mathworks.SPAMPROOFcom> wrote in message <ieaqq4$sk5$1@fred.mathworks.com>...
> Glad to see this code is still useful.  I agree with the above suggestion.  If you are still having problems, please contact me.
> 
> Doug
0
Reply Anitha 12/18/2010 2:24:07 PM

On 18/12/10 8:24 AM, Anitha wrote:
> I am still not sure how I can change it to a vector and non-sparse. It
> is a 1 by 1 by 25 double array now.

> for i = startFrame:endFrame

> move_bw_plane_of_interest(:,:,i) = im2bw(move_image(:,:,i),
> graythresh(move_image(:,:,i)));

move_image(:,:,i) is going to be the i'th frame of a movie image, right? 
So then move_image(:,:,i) would be a 2D array rather than a vector. 
im2bw() is going to retain that 2D array shape, so 
move_bw_plane_of_interest is going to be a 2D array.

> move_plane_of_interest_segmented(:,:,i) =
> bwmorph(move_bw_plane_of_interest(:,:,i), 'open');

Taking the morphology of a 2D shape returns a 2D shape.

> move_binary_mask(:,:,i) =
> imfill(move_plane_of_interest_segmented(:,:,i), 'holes');

Filling a 2D shape returns a 2D shape.

> move_properties(:,:,i) = regionprops(real(move_binary_mask(:,:,i)),'all');

Taking the region properties of a 2D array will return a structure array 
vector with one element per identified object. As the only values in 
your array are 0's and 1's, you will have only one identified object, 
and hence the structure array will have one element.

> move_centroid_row(:,:,i) = round(move_properties(:,:,i).Centroid(2));
> move_centroid_col(:,:,i) = round(move_properties(:,:,i).Centroid(1));

Those copy scalars, so move_centroid_row and _col will be 1 by 1 by the 
frame number

> move_image(move_centroid_row(:,:,i), move_centroid_col(:,:,i), 1) = 255;
> move_image(move_centroid_row(:,:,i), move_centroid_col(:,:,i), 2) = 255;
> move_image(move_centroid_row(:,:,i), move_centroid_col(:,:,i), 3) = 255;

In the im2bw() call, you retrieved move_image(:,:,i) but here you are 
setting move_image(r,c,1:3) which is presumably _intended_ to affect the 
R, G, and B channels of something. Instead it is going to affect frames 
1 to 3. Unless, that is, move_image is intended to be an RGB color 
image, in which case if your start or end frame are more than 3 you 
would have bombed out immediately...

> move_image(:,:,i) = make_odd_by_odd1(move_image(i));

Here you extract the element of move_image which happens to have the 
same offset as the frame number. Offsets in arrays run down the first 
column, then down the second, so until you get to a frame number which 
happens to be as large as the image height, you will be retrieving the 
left-hand border of the first frame. You make that value odd, and store 
it at _all_ locations in the current frame.

Things get weirder after that.

I would suggest that you need to rethink your code. And if you are 
storing a single scalar value to create a vector, please do not confuse 
the readers by storing it in to a 3D array indexed at (:,:,i) -- just 
use (i) instead.
0
Reply Walter 12/20/2010 5:48:28 AM

4 Replies
365 Views

(page loaded in 0.535 seconds)

Similiar Articles:











7/23/2012 2:30:51 PM


Reply: