Extract RGB value to decode

9 次查看(过去 30 天)
NITIN TIWARI
NITIN TIWARI 2019-4-5
I'm trying to create a 2D Colour Barcode steganography which decodes a barcode into its corresponding text. On clicking the "Decode" button, the image must be decoded into its textual form.
I have given red, green, yellow and blue colours for letters A, B, C, D respectively. I want to decode this image by making use of RGB pixel values which will decide what's the letter.
The expected output for above image is ADBCD. Please help me!
[File_Name, Path_Name] = uigetfile('D:\'); %upload image by clicking on "Upload" button
axes(handles.graph)
imshow([Path_Name,File_Name]) %display image on axes in GUI window

回答(1 个)

Walter Roberson
Walter Roberson 2019-4-5
rgb2ind passing in a colormap of your four colors to get color indices.
  9 个评论
Walter Roberson
Walter Roberson 2019-4-7
bwareafilt(mask0, SomeParameterGoesHere) %get rid of small accidental matches
NITIN TIWARI
NITIN TIWARI 2019-4-9
编辑:NITIN TIWARI 2019-4-9
function decode_Callback(hObject, eventdata, handles)
global img %using the global variable 'img' from the "upload" function
index=1; %initialise index of 'text' variable to 1
for i=150:200:1024
red=img(500,i,1); %extract value of 'R' at (500,i)
green=img(500,i,2); %extract value of 'G' at (500,i)
blue=img(500,i,3); %extract value of 'B' at (500,i)
if(red==255&&green==0&&blue==0)
text(index)='A'; %store the letter 'A' in array 'text'
index=index+1; %increment the index for next colour
set(handles.out,'string',text);
elseif(red==0&&green==255&&blue==0)
text(index)='B'; %store the letter 'B' in array 'text'
index=index+1; %increment the index for next colour
set(handles.out,'string',text);
elseif(red==255&&green==255&&blue==0)
text(index)='C'; %store the letter 'C' in array 'text'
index=index+1; %increment the index for next colour
set(handles.out,'string',text);
elseif(red==0&&green==0&&blue==255)
text(index)='D'; %store the letter 'D' in array 'text'
index=index+1; %increment the index for next colour
set(handles.out,'string',text);
end
end
Hey Walter, this is what I tried doing for decoding the image into text. I'm getting output as expected. The only thing I'm lacking in my code is to give automatic spacing between the colours. In my code, I have chosen a spacing of 200 pixels. This works well only if there are 5 columns (colours). If the no. of columns increase, their width will decrease and if the no. of columns decrease, their width will increase. So, the idea of increasing the x-coordinate by 200 will not work everytime. This is the only thing that remains to be done. Would you please help me out?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by