Len = norm(lines(cnt).point1 - lines(cnt).point2) Lines = houghlines(BW2,T,R,P,'FillGap',5,'MinLength',7) % Find the skew angle by using hough transform Stats = regionprops(BW1, 'Area', 'FilledImage') ProcessImgSegment = BW_ProcessImg(y1:y2, x1:x2) Rectangle('Position', 'EdgeColor', 'Red', 'LineWidth',2) H = Filtered_HProSegment(i,2) - Filtered_HProSegment(i,1) Įnd % for j=1:size(VProSegment.Profile(j,1) If(density > LLimit_Density) & (density LLimit_Area) & (area LLimit_HWratio) & (HWratio LLimit_GradientMagnitude) & (GradientMagnitude LLimit_TotalArea) & (TotalArea = LLimit_NumOfCharacter) & (cc.NumObjects RatioBetweenSpaceDistAndAvrDist). Y2 = ceil(stats(cnt).BoundingBox(2) + stats(cnt).BoundingBox(4)) X2 = ceil(stats(cnt).BoundingBox(1) + stats(cnt).BoundingBox(3)) Adding the missing options should now be much easier.HWratio = (stats(cnt).BoundingBox(4)/stats(cnt).BoundingBox(3)) ĭensity = stats(cnt).Area / (stats(cnt).BoundingBox(3)*stats(cnt).BoundingBox(4)) These are still not completely implemented and generally restricted to 2D transforms. Pantxo Diribarne has also submitted a set of functions for spatial transformations: maketform, cp2tform, tformfwd, and tforminv. To create a non-flat SE, use the arbitrary shape of strel. These heights are added to the image pixels values before the erosion and dilation, in the same way as the variable S in ordfiltn.īasically, not useful for volumes at all but the image package can do this now. A non-flat SE is defined by two different matrices, one defining the neighbourhood (same as a flat SE) and another defining the height of each neighbour. The fact that the only non-flat standard shape in matlat is named ball, which immediately brings up the idea of volume, also helped to the confusion.Īctually, non-flat morphology is something that only makes sense for grayscale operations. Because of the name (non-flat), and because 3D images are the norm for me, I have always assumed that a non-flat SE was one used for volumes. This has confused me for a very long time. Note that non-flat is unrelated to volumes. I also wanted to implement ball as a volume but unfortunately, matlab has already done it wrong as a non-flat ellipsoid. On top of the matlab shapes for strel, I implemented the cube as an optional shape. I'm a bit interested in morphology of volumes so one of the changes made was making them work for N-dimensional images (think MRI scans). Going through imdilate() and imerode() to make them use strel, brought up a bunch of other matlab incompatibilities that I hope are now fixed, as well as other improvements. The only file where this is done is so send us patches. This means that when it is implemented for another shape, its effect will be immediate across the whole image package. Functions that can gain from SE decomposition, are written so that it does not matter if it has been implemented for a specific shape. Octave> im2 = conv2 (im2, true (1, 20), "same") > 0 # dilation by 1 rowĪt the moment, decomposition is only being done for rectangular, square and cube shapes but other will come with time. Octave> im2 = conv2 (im2, true (20, 1), "same") > 0 # dilation by 1 column Octave> im1 = conv2 (im1, true (20), "same") > 0 # dilation by 1 square For an example on performance, see how the use of a square compares to use of 1 row and 1 column of the same size: However, some SE can be replaced by a sequence of smaller ones so it's in our best interest to use them. The bigger the SE, the slower it will be. The idea behind SE decomposition is that morphology operations take as much space as the number of pixels in a SE. All the basic methods have been implemented: the object constructor, getnhood, getheight and reflect. m function, no OOP at all, but he managed to implement with the old style while keeping matlab compatibility. Roberto Metere submitted his own implementation of the class last month and we have been working on it, slowly adding it to the other functions of the package. Specially, SE decomposition can have a really nice increase in performance. I have only seen it as a standard way to create SEs, but is actually much more. The name strel comes from structuring element (SE), the shapes used in morphological operations such as dilation and erosion. The strel class was something that I wanted to implement a long time ago but had never found the time. If you can't get development version from subversion, please give this tarball a try (prepared from revision 11551). While these have not been tested enough for a release, they're on a state where we could welcome some testing. There's been a lot of development on the image package lately, spurred by contributions from Pantxo Diribarne and Roberto Metere.