﻿a=52+7*i;
b=139+128*i;
c=10+95*i;
d=87+217*i;

%a=3*a;
%b=3*b;
%c=3*c;
%d=3*c;

%cr=((a-b)*(c-d))/((a-d)*(c-b));

%H=sqrt(-1/cr);
h=0.7;
%h=1.2;
%a=[1 2 3;4 5 6];
%image(a)

N=200;
S=1;
Nh=round(N*h);

t=linspace(0,1,N);
s=linspace(0,1,Nh);

A=imread('sbook.jpeg');
%A=imread('sbook.jpeg');

%R=A(:,:,1);
%G=A(:,:,2);
%B=A(:,:,3);
%W=R+G+B;

%[n1,m1]=find(and(R>200,1));
%[n2,m2]=find(and(G>200,1));
%[n3,m3]=find(and(B>200,1));
%[n4,m4]=find(and(R>200,1));
%a=n1(1)*i+m1(1);
%b=n2(1)*i+m2(1);
%c=n3(1)*i+m3(1);
%d=n4(1)*i+m4(1);


%A=A(:,:,3);
B=floor(A/2);

for k=1:N
    for l=1:Nh
%p=(a+(b-a)*t(k))*(1-s(l))+c*s(l);
p=a*(1-t(k))*(1-s(l))+b*t(k)*(1-s(l))+c*(1-t(k))*s(l)+d*t(k)*s(l);
%P=p*7+3+3*i;
%P=S*P+15+10*i;
P=p+2+2*i;
x=floor(real(P));
y=floor(imag(P));
fx=real(P)-x;
fy=imag(P)-y;
%f(k,l,:)=A(x,y,:); %simple
f(k,l,:)=A(x,y,:)*(1-fx)*(1-fy)+A(x+1,y,:)*fx*(1-fy)+A(x,y+1,:)*(1-fx)*fy+A(x+1,y+1,:)*fx*fy;
B(x,y,:)=A(x,y,:);
end
end
imshow(f)
imshow(B)