i am applying Arnold's transform on the pixels

1 次查看(过去 30 天)
Hi, I am writing a code for the following transformation
T[x;y]=[x+y:x+2y]
the code is
n=256;
I=imread('fruit1.bmp');
Red=I(:,:,1);
Green=I(:,:,2);
Blue=I(:,:,3);
x(1)=Red(1);
y(1)=Green(1);
for i=1:15
x(i+1)=mod(x(i)+y(i),n)
y(i+1)=mod(x(i)+2*y(i),n)
end
[x; y]
but I am getting the following results,which is definitley wrong.Can any one tells me why I am getting 255.
227 255 255 255 255 255 255 255 255 255 255 255 255 255 255
213 255 255 255 255 255 255 255 255 255 255 255 255 255 255
Column 16
255

采纳的回答

Guillaume
Guillaume 2019-8-13
Your image is of type 'uint8'. This means the range of intensities is between 0 and 255 (included). If you sum two uint8 and the result is greater than 255, the sum gets clamped to 255. If you subtract two uint8 and the result is less than 0, you'll get 0.
The simplest way to fix that problem is to convert your original image to double:
I = double(imread('fruit1.bmp')); %don't use im2double if you want the intensities to stay as 0-255
I have no idea what this notation mean:
T[x;y]=[x+y:x+2y]
and I've never heard of Arnold's transform. I assume it's this, in which case your notation is missing the mod.
But if that's what you're trying to implement, then your code has many problems:
  • Your current code depends on the red and green intensity of the 1st pixel only, since the only thing that influences the result of the loop is the value of x(1) and y(1) before the loop. As a transform, that's hardly useful.
  • The cat transformation described in the wikipedia article I've linked, alters the location of the pixels (jhence the use of x, y) not the colour of the pixels (what you're currently doing).
  1 个评论
sadiqa ilyas
sadiqa ilyas 2019-8-13
Thanks. your suggestion to use double in the oriinal image is useful. I am trying to apply Arnold's cat transform and for this I trying to write my own code to learn Matlab.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by