Convolve text with image

4 views (last 30 days)
Obaid Ullah
Obaid Ullah on 2 Jan 2022
Commented: Obaid Ullah on 25 Jan 2022
I am working on steganography, using morse code method. I want to convolve my output with image so that my info got hidden and then again retrieve my hidden code from image and display it.
clc
load data.mat
in_text = 'let''s decode';
fprintf('Input : %s\n', in_text);
text= lower(in_text);
len = length(text);
mor = [];
for i=1:len
if text(i)== ' '
mor = [mor '/'];
elseif isvarname(text(i))
mor = [mor getfield(morse,text(i))];
mor = [mor ' '];
elseif ~isempty(str2num(text(i)))
mor = [mor getfield(morse,[ 'n',text(i)])];
mor = [mor ' '];
elseif findstr(text(i),morse.sc)
mor = [ mor char(morse.scv(findstr(text(i),morse.sc)))];
mor = [mor ' '];
end
end
fprintf('Output : %s\n',mor);
%%decode
code = mor;
deco = [];
code = [code ' '];
lcode =[];
for j=1:length(code)
if(strcmp(code(j),' ')|strcmp(code(j),'/'))
for i=double('a'):double('z')
letter = getfield(morse,char(i));
if strcmp(lcode,letter)
deco = [deco char(i)];
end
end
for i= 0:9
numb = getfield(morse,['n',num2str(i)]);
if strcmp(lcode,numb)
deco = [deco,num2str(i)];
end
end
for i=1:4
scv=char(morse.scv(i));
if strcmp(lcode,scv)
deco = [deco, morse.sc(i)];
end
end
lcode = [];
else
lcode = [lcode code(j)];
end
if strcmp(code(j),'/')
deco = [deco ' '];
end
end
fprintf('Decoded : %s\n',deco);
  1 Comment
DGM
DGM on 5 Jan 2022
Edited: DGM on 5 Jan 2022
Without knowing the details of what got loaded into the workspace
load data.mat
or what otherwise undefined things like 'morse' are, it's difficult to know what exactly is supposed to be happening here.
Is this all just table lookup with a bunch of loose named variables instead of a lookup table?
What is convolution of a char vector and an image supposed to do? It will result in a blurred, out-of-scale image. Since that's not likely intended, what is intended?

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 2 Jan 2022
Edited: Walter Roberson on 2 Jan 2022
mor = '.... .- .--. .--. -.-- / -. . .-- / -.-- . .- .-. -.-.--';
mord = im2double(uint8(mor));
img = im2double(imread('cameraman.tif'));
cimg = conv2(img, mord, 'same');
cimg8 = im2uint8(cimg);
imshow(img);
title('cameraman')
imshow(cimg8)
title('convolved')
[min(cimg(:)), max(cimg(:))]
ans = 1×2
0.4090 6.8147
imshow(cimg, [])
title('convolved, rescaled')
  20 Comments
Walter Roberson
Walter Roberson on 25 Jan 2022
Notice that the data range for dcimg (Deconvolved version of convn() with 'same' option) is about +/- 1e11 whereas the data range for dcimgfull (Deconvolved version of conv() without 'same' option) is about 0 to 1.
Imagine that you multiply together two six-digit numbers; the result would normally be anywhere from 6 to 12 digits. But suppose you say, "Oh, get rid of everything except the last 6 digits of the result, because it is more convenient to me to have the result the same size as the original numbers." And then you take the clipped result and divide by one of the numbers, and you expect to get out the other number in full, and you are surprised when it does not work. But of course you need to keep all of the digits of the result of the multiplication in order for the division to work properly.
Obaid Ullah
Obaid Ullah on 25 Jan 2022
Thanks for the help...

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!