## Re: [Vxl-users] Questions about some functions!!!

 Re: [Vxl-users] Questions about some functions!!! From: Amitha Perera - 2007-02-15 16:23:11 ```On Tue 13 Feb 2007, Julio Pastrana wrote: > 1) bwarea(binaryimage) > Estimates the area of the "on" pixels of BW. vil_math_sum > 2)) Is there a function like the following one in octave: > > b = bwborder(binaryimage) %% where im is a binary matrix > b is the borders in the 0-1 matrix im. 4-neighborhood is > considered. > A pixel is on the border if it is set in im, and it has at least > one neighbor that is not set. Repeated calls to vil_blob_finder::next_4con_region > 3) Can I do a XOR between 2 matrix. > > like in Octave I can do xor(A,B) where A and B are matrix Use a for loop. > 4) How can I use the VNL matrix operations with the vil_image types, is > there a wraper that cast my image matrix into a vnl_matrix (e.g) > > vil_image_view to vnl_matrix > > somthing like the "vil_convert_cast" but for VIL -> VNL and > viceversa No easy way in general. If the images are contiguous, you could use a vnl_matrix_ref: assert( img.is_contiguous() && img.nplanes() == 1 ); vnl_matrix_ref mat( img.nj(), img.ni(), img.top_left_ptr() ) > > 5) Convolution ( I already asked this question but no one answered ) > > How do I get rid of the border after a convolution > do I need to add some extra rows and colunms with zeros. > > I want a convolution that yileds on a matrix of the same size. The convolution in vil will not do the borders, because the kernel will not fit. If you want the borders done, you'll have to extend the source image as you want. Otherwise, put the dest image back into a properly sized image. vil_image_view full_dest; vil_image_view cropped_dest = vil_crop( full_dest, kernel.ni()/2, 1+src_im.ni()-kernel.ni(), kernel.nj()/2, 1+src_im.nj()-kernel.nj() ); cropped_dest.deep_copy( dest ); You may also be able to do the convolution directly into the crop (untested) vil_image_view full_dest; vil_image_view cropped_dest = vil_crop( full_dest, kernel.ni()/2, 1+src_im.ni()-kernel.ni(), kernel.nj()/2, 1+src_im.nj()-kernel.nj() ); vil_convole_2d( src, cropped_dest, kernel, double() ); Amitha. ```

 [Vxl-users] Questions about some functions!!! From: Julio Pastrana - 2007-02-13 16:21:49 ```Dear VXL users I would like to ask about some functions that exist in Matlab/Octave and I want to know if there something similar in VXL. I apologise for any inconvinience that these questions may cause I am still trying to learn VXL (newvie newvie) 1) bwarea(binaryimage) Estimates the area of the "on" pixels of BW. 2)) Is there a function like the following one in octave: b = bwborder(binaryimage) %% where im is a binary matrix b is the borders in the 0-1 matrix im. 4-neighborhood is considered. A pixel is on the border if it is set in im, and it has at least one neighbor that is not set. 3) Can I do a XOR between 2 matrix. like in Octave I can do xor(A,B) where A and B are matrix 4) How can I use the VNL matrix operations with the vil_image types, is there a wraper that cast my image matrix into a vnl_matrix (e.g) vil_image_view to vnl_matrix somthing like the "vil_convert_cast" but for VIL -> VNL and viceversa 5) Convolution ( I already asked this question but no one answered ) How do I get rid of the border after a convolution do I need to add some extra rows and colunms with zeros. I want a convolution that yileds on a matrix of the same size. Thank you vxl-users I will appreciate any contributions =) Julio ```
 Re: [Vxl-users] Questions about some functions!!! From: Amitha Perera - 2007-02-15 16:23:11 ```On Tue 13 Feb 2007, Julio Pastrana wrote: > 1) bwarea(binaryimage) > Estimates the area of the "on" pixels of BW. vil_math_sum > 2)) Is there a function like the following one in octave: > > b = bwborder(binaryimage) %% where im is a binary matrix > b is the borders in the 0-1 matrix im. 4-neighborhood is > considered. > A pixel is on the border if it is set in im, and it has at least > one neighbor that is not set. Repeated calls to vil_blob_finder::next_4con_region > 3) Can I do a XOR between 2 matrix. > > like in Octave I can do xor(A,B) where A and B are matrix Use a for loop. > 4) How can I use the VNL matrix operations with the vil_image types, is > there a wraper that cast my image matrix into a vnl_matrix (e.g) > > vil_image_view to vnl_matrix > > somthing like the "vil_convert_cast" but for VIL -> VNL and > viceversa No easy way in general. If the images are contiguous, you could use a vnl_matrix_ref: assert( img.is_contiguous() && img.nplanes() == 1 ); vnl_matrix_ref mat( img.nj(), img.ni(), img.top_left_ptr() ) > > 5) Convolution ( I already asked this question but no one answered ) > > How do I get rid of the border after a convolution > do I need to add some extra rows and colunms with zeros. > > I want a convolution that yileds on a matrix of the same size. The convolution in vil will not do the borders, because the kernel will not fit. If you want the borders done, you'll have to extend the source image as you want. Otherwise, put the dest image back into a properly sized image. vil_image_view full_dest; vil_image_view cropped_dest = vil_crop( full_dest, kernel.ni()/2, 1+src_im.ni()-kernel.ni(), kernel.nj()/2, 1+src_im.nj()-kernel.nj() ); cropped_dest.deep_copy( dest ); You may also be able to do the convolution directly into the crop (untested) vil_image_view full_dest; vil_image_view cropped_dest = vil_crop( full_dest, kernel.ni()/2, 1+src_im.ni()-kernel.ni(), kernel.nj()/2, 1+src_im.nj()-kernel.nj() ); vil_convole_2d( src, cropped_dest, kernel, double() ); Amitha. ```