Skip to content

Instantly share code, notes, and snippets.

@Wolwer1nE
Created April 8, 2020 07:54
Show Gist options
  • Save Wolwer1nE/c52e4823a8c253e51f1338daec0f8936 to your computer and use it in GitHub Desktop.
Save Wolwer1nE/c52e4823a8c253e51f1338daec0f8936 to your computer and use it in GitHub Desktop.
function [output] = addText(image, text)
red_data = image(:,:,1);
text = strcat(num2str(length(text), '%03.f'), text);
binary_data = dec2bin(text)';
data_to_encode = str2num(binary_data(:));
for i = 1:length(data_to_encode)
red_data(i) = bitset(red_data(i), 1, data_to_encode(i));
end
output = image;
output(:,:,1) = red_data;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment