Hi, i am working on GUI project.I wan that the below given code should take the pixel range (here: 38,333,334,etc.) from user and the display it.

u=multibandread('paris.lan',[512,512,7],'uint8=>uint8',128,'bil','ieee-le'); Nof_bands=7; for k=1:Nof_bands t_value=u(:,:,k);
x(k)=double(t_value(38,333));
y(k)=double(t_value(38,334));
z(k)=double(t_value(39,333));
b(k)=double(t_value(39,334));
x1(k)=double(t_value(486,115));
y1(k)=double(t_value(486,116));
z1(k)=double(t_value(487,115));
b1(k)=double(t_value(487,116));
avg(k)=double(x(k)+y(k)+z(k)+b(k))/4;
avg1(k)=double(x1(k)+y1(k)+z1(k)+b1(k))/4;
end
d=[1:1:7];
figure(1)
plot(d,avg,'r',d,avg1,'g');

2 Comments

Do you want the user to give input by clicking at a particular point, or using an input field?
i want the userto give input by clicking at particular 4 point. As i have done in above code.

Sign in to comment.

 Accepted Answer

User input from mouse Please check the above link. If you want 4 points as you mention in your comment, you can do
[x,y] = ginput(4)
The link in the answer gives more documentation on what you need to do for different use cases.

3 Comments

I tried,but error occured-- tru=multibandread('paris.lan',[512,512,7],'uint8=>uint8',128,... 'bil','ieee-le',{'Band','Direct',[4,2,3]}); figure, imshow(tru); [x,y]=ginput(1); [xx,yy]=ginput(1); [xxx,yyy]=ginput(1); [xxxx,yyyy]=ginput(1);
for k=1:7;
t_value=tru(:,:,k);
X(k)=t_value(x,y);
Y(k)=t_value(xx,yy);
Z(k)=t_value(x,y);
b(k)=t_value(xx,yy);
x1(k)=t_value(xxx,yyy);
y1(k)=t_value(xxxx,yyyy);
z1(k)=t_value(xxx,yyy);
b1(k)=t_value(xxxx,yyyy);
avg(k)=(X(k)+Y(k)+Z(k)+b(k))/4;
avg1(k)=(x1(k)+y1(k)+z1(k)+b1(k))/4;
end
d=[1:1:7];
figure, plot(d,avg,'r',d,avg1,'g')
title('actual signals');
%%%correlation between avg and avg1 z=xcorr2(avg,avg1); figure(2), plot(z) title('correlation of 2 signals'); %%%%error mm=double(avg)-double(avg1);
figure(3), plot(d,mm) title('error of 2 signals'); % error
dS = double(abs(mm)); percentageDifference = double(dS./ double(avg)); % Percent by element.
figure(4), plot(percentageDifference,'r') title('% difference of 2 signals');
It isn't clear from your comment what the error is or where it is occurring. I would advise using an array instead of making several variables with names like x,xx,xxx,xxxx and so on. You also should improve your indentation. Each subsequent line inside a loop doesn't need to be progressively indented with respect to the previous line. The indent should be the same for all lines inside a condition, function, or a loop.
im=multibandread('paris.lan',[512,512,7],'uint8=>uint8',128,'bil','ieee-le'); [a,b]=ginput(1); [xx,yy]=ginput(1); [xxx,yyy]=ginput(1); [xxxx,yyyy]=ginput(1); Nof_bands=7; for k=1:Nof_bands t_value=im(:,:,k);
X(k)=double(t_value(a,b));
Y(k)=double(t_value(a,yy));
Z(k)=double(t_value(xx,b));
b(k)=double(t_value(xx,yy));
x1(k)=double(t_value(xxx,yyy));
y1(k)=double(t_value(xxx,yyyy));
z1(k)=double(t_value(xxxx,yyy));
b1(k)=double(t_value(xxxx,yyyy));
avg(k)=double(X(k)+Y(k)+Z(k)+b(k))/4;
avg1(k)=double(x1(k)+y1(k)+z1(k)+b1(k))/4;
end
z=xcorr2(double(avg),double(avg1));
axes(handles.axes2);
%%RELATE BOTH CODES,GIVE BELOW AND ABOVE
u=multibandread('paris.lan',[512,512,7],'uint8=>uint8',128,'bil','ieee-le'); Nof_bands=7; for k=1:Nof_bands t_value=u(:,:,k);
x(k)=double(t_value(38,333));
y(k)=double(t_value(38,334));
z(k)=double(t_value(39,333));
b(k)=double(t_value(39,334));
x1(k)=double(t_value(486,115));
y1(k)=double(t_value(486,116));
z1(k)=double(t_value(487,115));
b1(k)=double(t_value(487,116));
avg(k)=double(x(k)+y(k)+z(k)+b(k))/4;
avg1(k)=double(x1(k)+y1(k)+z1(k)+b1(k))/4;
end

Sign in to comment.

More Answers (0)

Tags

Asked:

on 5 Jul 2018

Commented:

on 6 Jul 2018

Community Treasure Hunt

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

Start Hunting!