How to recover the barcode after the use of imdilate()
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I was trying to merge the barcode together so that I can remove the background object. After doing so, I was wondering how can I recover back the the barcode. Below are the image and the coding(I know there is a lot of loop holes in the coding).
Orignal Image
Processed Image
% Read Image
rgb = imread('barcode.jpg');
% Resize Image
rgb = imresize(rgb,0.33);
% Convert from RGB to Gray
Igray = rgb2gray(rgb);
% Threshold to minimize the intraclass variance
Ibw = im2bw(Igray, graythresh(Igray));
% Inverse Colour
Ibw = ~Ibw;
% Clear Border
Iarea = imclearborder(Ibw);
% Remove Small object
Iarea = bwareaopen(Iarea,50);
masklen = 80;
Imask = zeros(1, masklen);
Imask(ceil(end/2):end) = 1;
rmask = fliplr(Imask);
block = imdilate(Iarea, Imask) & imdilate(Iarea, rmask) ;
block = bwareaopen(block,10000);
imshow(block);
0 comentarios
Respuesta aceptada
Image Analyst
el 10 de En. de 2012
Did I already give you code for that in your prior question on this subject? Anyway, just multiply your "block" by "rgb" - here's a new and different way for you (Sean's method):
% Mask the image.
maskedRgbImage = bsxfun(@times, rgb, cast(block,class(rgb)));
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Processing Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!