Search code examples
matlabimage-processingtext-extractionimage-segmentationmatlab-cvst

what's the common way for segmenting a text from an image using matlab?


I have searched about this field and I found some papers that present new methods to extracting texts from images, but I have a grayscale image consists of a simple background and some texts.so I need a method that everyone works with it. please provide details on how this can be done.


Solution

  • Here an article about text segmentation.

    the article

    And here an easy way to segment your image in 2 class.

    I = imread('...'); % Your board image
    ThreshConstant = 1; % Try to vary this constant.
    
    bw = im2bw(I , ThreshConstant * graythresh(I)); % Black-white image
    
    SegmentedImg = I.*repmat(uint8(bw), [1 1 3]);
    

    Just do imshow(bw); and you will have a 2 color image normally well segmented.

    If the threshold is too strong, try to turn around 0.5 to 1.5 with ThreshConstant.