How to Store ASCII Values to a new Text values obtained from RGB values of a Image????

1 view (last 30 days)
OK I am trying to Distort an Image using a text file by writing the RGB values with ASCII value of a text file. Also I want to store original text from new RGB values which are ASCII values of a text. When I am using Big text file it is not working.

Answers (1)

Image Analyst
Image Analyst on 22 Nov 2014
Your image does not look like it's RGB. Maybe it is but all the red, green, and blue channels are the same so it just appears gray. You should never use size() with images like this:
[m n]=size(I); % VERY BAD ON IMAGES!!!
Instead you should do this:
[m n, numberOfColorChannels]=size(I); % Best way to do it.
Why? Because if you do it your way, the (badly-named) "n" will actually be the number of columns times the number of color channels. In other words, n will be 3*n for a color image and NOT the actual number of columns in the image. See Steve's Blog Posting
And I really don't know what you're doing. The code does not distort the image. See http://en.wikipedia.org/wiki/Distortion_%28optics%29 for a definition of distortion. It seems to be doing some kind of weird watermarking where it's replacing pixel values with ASCII values of text pulled from a text file. This would be a very visible, but noisy, watermark. I don't know why this would be desirable.
  3 Comments
Image Analyst
Image Analyst on 22 Nov 2014
Just do the same loops but don't assign I, instead build up c, like this:
c(k) = I(ii,j);
Image Analyst
Image Analyst on 23 Nov 2014
What is not working? Can't you just do something like I said:
for ii=1:m
for j=1:n
k = k+1;
if (k>=xx)
break;
end
c(k) = I(ii,j);
end
end
c is now your original ascii values. What code did you do such that it did not work?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!