"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i7iibb$1hp$1@fred.mathworks.com>...
>
> > Dear ImageAnalyst,
> >
> > I haven't been able to use the bwboundaries function as the current version for the Image Processing Toolbox I am using is v3.1 which does not include the bwboundary function. However, I have seen that it is based on the MooreNeighbor tracing algorithm so I will have a look at that.
>
> Does your version have the conv2() function? If so then a very fast way to detect the boundary pixels from a logical mask is:
>
> >>my_bounds = (conv2(double(M),ones(3),'same')<8)&M; %M is mask
>
> %In an example:
> M = imread('cameraman.tif')<100;
> my_bounds = (conv2(double(M),ones(3),'same')<8)&M;
My version does include the conv2() function however I cannot visualise whether or not the cell boundaries are being detected properly.
As I have 10 cells in total, is there a way I can trace the boundaries to make sure all 10 boundaries are being detected correctly. Furthermore, do you think in order to calculate the relevant distances to the relevant cells, I could calculate the BoundingBox for each cell. I would then set up 2 loops which would calculate the distances of the cmet vesicles between the cell and nuclei boundaries for each particular bounding box.
This can be illustrated via the following picture
http://img691.imageshack.us/i/exampleth.png/ where the green line is the cell boundary, the red line is the nuclei boundary and the orange dots are vesicles.
I have read a paper where the cell boundaries were interactively determined however I am not sure what this entitles.
>
> > My main problem is in calculating the distances. Having labelled the nuclei and cmet vesicles, I think I can calculate the minimum distance (straight line) between the two. However, I would I then calculate the distance between the cmet vesicle and the cell boundary. Are there any algorithms which would allow me to calculate the distances for all the cmet vesicles in Cell 1,2 and so forth?
>
>
> If I understand you correctly:
> Get coordinates of the nuclei and calculate distance from that to the edge using a basic distance formula. Label the my_bounds image from above as you have done before and then find them one at a time.
> I would use a cell array:
>
> nlabel = max(labelledImage(:));
> my_bounds_cell_array = cell(nlabel,1);
> for ii = 1:nlabel
> [r c] = find(labelledImage == ii);
> my_bounds_cell_array{ii} = [r,c];
> end
>
> Now put all of your centroid coordinates in another cell array of the same size and use cellfun to calculate distances:
> centroid_cell = ...;%centroids where each row of the cell array contains a cell with [r_centroid,c_centroid]
>
> distances = cellfun(@(x,y)sqrt(sum((x(:,1)y(1)).^2+(x(:,2)y(2)).^2,2)),my_bounds_cell_array,centroid_cell,'uni',false);
>
> Now to find the minimum distance, use cellfun again:
> min_dist = cellfun(@(x)min(x),distances);
>
> %%A few ideas
> %I haven't tested this or had it in the MATLAB window so it may be missing a ( or something.
> %Sean
Thanks so much for providing some help however I do not understand your methodology notably setting up the arrays. Please bare with me, I am quite new to MATLAB.
