Reputation: 35
I am making a traffic sign detection and recognition program in MATLAB for my semester project. By now I have been successful in doing every step correct.
Image >> Normalized Image >> Scaling & Intensifying Image >> Thresholding >> Morphological Operations
I have normalized the image by using this formula:NORM_COLOR = COLOR/sqrt(RED^2 + GREEN^2 + BLUE^2);
I have scaled my image by the factor of sqrt(3) and intensified by element-wise multiplication to the normalized image.
In thresholing, I have zeroed all three channels (RGB) where this condition is true:
RED < 0.34 OR GREEN > 0.2621
This all gives me an image where all colors (excluding red) are blacked. This is the image I get: Image
Now, when I do morphological operations like imerode
it gives me this error:
Error using morphmex
Input image may not contain NaNs.Error in morphop (line 69)
B = morphmex(mex_method, B, double(getnhood(se(k))), getheight(se(k)), unpacked_M);Error in imerode (line 123)
B = morphop(A,se,'erode',mfilename,varargin{:});Error in anas (line 64)
img_seg = imerode(img,se);
This is the code I have written for erosion:
se = strel('disk', 2);
img_seg = imerode(img,se);
imshow(img_seg);
Any one could help me with this problem? Thankyou :)
Upvotes: 2
Views: 74
Reputation: 35525
Try avoiding division by zero:
NORM_COLOR = COLOR/sqrt(RED^2 + GREEN^2 + BLUE^2+0.0000001);
Upvotes: 1