i am applying Arnold's transform on the pixels

조회 수: 1 (최근 30일)
sadiqa ilyas
sadiqa ilyas 2019년 8월 13일
댓글: sadiqa ilyas 2019년 8월 13일
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