Effacer les filtres
Effacer les filtres

How to recover the barcode after the use of imdilate()

1 vue (au cours des 30 derniers jours)
Kim
Kim le 10 Jan 2012
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);

Réponse acceptée

Image Analyst
Image Analyst le 10 Jan 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)));

Plus de réponses (0)

Catégories

En savoir plus sur Computer Vision with Simulink dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by