Skip to content

Instantly share code, notes, and snippets.

@Wolwer1nE
Created April 7, 2020 06:00
Show Gist options
  • Save Wolwer1nE/f4d1ce933912b6bb82e9954e4eabb45b to your computer and use it in GitHub Desktop.
Save Wolwer1nE/f4d1ce933912b6bb82e9954e4eabb45b to your computer and use it in GitHub Desktop.
function [output] = addText(input, text)
red_data = input(:,:,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 = input;
output(:,:,1) = red_data;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment