braille recognition using image processing
Show older comments
i have a braille character recognition research and i'm not very good in matlab .. i want to know how to compute the centroids of dots and do alignment for it and make cells of braille characters ..

this is my code
RGB = imread('braille.jpg');
I = rgb2gray(RGB);
I2 = imcrop(I,[14.5100 3.5100 189.9800 134.9800]);
h = ones(5,5) / 25;
I3=imfilter(I2,h);
I4 = imadjust(I3);
I5 = imcomplement(I4);
se = strel('disk',1);
I6 = imdilate(I5,se);
I7 = im2bw(I6, 0.4);
subplot(4,4,1)
imshow(RGB)
title('rgb')
subplot(4,4,2)
imshow(I)
title('gray Image')
subplot(4,4,3)
imshow(I2)
title('Cropped Image')
subplot(4,4,4)
imshow(I3)
title('filtered Image')
subplot(4,4,5)
imshow(I4)
title('contrast Image')
subplot(4,4,6)
imshow(I5)
title('complement Image')
subplot(4,4,7)
imshow(I6)
title('dilate Image')
3 Comments
Star Strider
on 7 May 2016
Your Question would be easier to Answer if you attach your 'braille.jpg' file.
Image Analyst
on 7 May 2016
And, is the image a profilometer image (so it's the height/topography) or is it an RGB image like you're casting brightness on the sides of the dots and shadows beside them?
Ismail Alrawi
on 7 May 2016
Answers (1)
Image Analyst
on 7 May 2016
This looks easy. First you need to decide the rows and columns that divide the image up into individual tiles for each character. Then you simply need to have a 3-by-2 template where you check each place in for the intensity. If it's dark it's a spot, if it's light it's paper
for k = 1 : 6
output(k) = subImage(row(k), col(k)) > 128
end
Then you can convert all the 6 output locations into an integer that is used in a look up table to give you the letter
index = 0;
for k = 1 : 6
index = index + 2^(k-1) * output(k);
end
theCharacter = yourLookUpTable(index);
16 Comments
Ismail Alrawi
on 7 May 2016
Image Analyst
on 7 May 2016
If you have the template location data and you want us to run it because you need more help, then sure, you can upload it.
I would think translation into English text is what is needed. Then you can have it read it with code like this:
% Program to do text to speech.
% Get user's sentence
userPrompt = 'What do you want the computer to say?';
titleBar = 'Text to Speech';
defaultString = 'Hello World! MATLAB is an awesome program!';
caUserInput = inputdlg(userPrompt, titleBar, 1, {defaultString});
if isempty(caUserInput)
return;
end; % Bail out if they clicked Cancel.
caUserInput = char(caUserInput); % Convert from cell to string.
NET.addAssembly('System.Speech');
obj = System.Speech.Synthesis.SpeechSynthesizer;
obj.Volume = 100;
Speak(obj, caUserInput);
Ismail Alrawi
on 7 May 2016
Image Analyst
on 8 May 2016
Follow my algorithm. Don't do the text to speech part if you don't want to - that's completely optional. Note that I did not say to do filtering or contrast adjustment. It's not necessary. Filtering is not needed unless it's noisy - so much so that there are pixels in the dots that are the same intensity as the background. I did not see anything like that so filtering is not needed.
I did do binarization in a way when I compared the value to 128, but I did it on just 6 pixels, not the whole image so this way it will be faster. The value you should compare it to is half way between the dark dot intensity and the bright background intensity.
Again, the fastest way is to measure just 6 locations, then use those to build an index, and then look up the translated character from the lookup table. Don't do a template matching like with normxcorr2() or anything - that will be slower than a lookup table.
Really, it's fast and super easy so don't make it more complicated and time consuming than it needs to be.
Ismail Alrawi
on 9 May 2016
Image Analyst
on 10 May 2016
No - you did anyway what I specifically told you not to do. Again, no contrast adjustment is needed. No filtering is needed. No complementing is needed. No dilation is needed And you didn't define the lookup table. All you need to do is to check intensities and use those to determine the look up table index and then read off the letter. I'll see if I can spend some time on it to get you a little farther along.
Image Analyst
on 10 May 2016
Ismail, try the attached .m file.

afif fadilah
on 8 Mar 2017
excus me sir,, i've try your code, but this can't run because "Undefined function 'histogram' for input arguments of type 'uint8'. Error in matriks (line 66) histogram(grayImage); " what's wrong sir ? i use matlab R2012.
Walter Roberson
on 8 Mar 2017
use hist() instead of histogram()
afif fadilah
on 8 Mar 2017
thank's sir, i use histeq () ,,
afif fadilah
on 8 Mar 2017
i have this image, what must i do for this image so that this image can running on your code ?

Walter Roberson
on 8 Mar 2017
histeq() and histogram() are completely different purposes; you cannot substitute histeq() for histogram(). hist() is the older routine that most closely matches histogram()
Image Analyst
on 8 Mar 2017
histogram() both computes the histogram and plots it. For an older version of MATLAB, you can use imhist() and bar():
[counts, grayLevels] = imhist(grayImage);
bar(grayLevels, counts];
grid on;
afif fadilah
on 10 Mar 2017
thank you sir, i want to ask again, what should i do for my image above so that my image can run use your code (m.file).
Image Analyst
on 10 Mar 2017
You need to change the line that says:
baseFileName = 'braille.jpg';
so that it refers to your image. Other than that, I don't know - just work through the code line by line and see what happens.
afif fadilah
on 13 Mar 2017
i know that, but that not what i ask, ok, thanks sir, i'll see
Categories
Find more on Images in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!