What is programming? Its not just adding keywords or arranging them. Its creative. Everybody has and must have their own style and way with it. Its okay to copy down someone else's program from sites like MATLAB Central or the others but they must be understood and converted to your own style and make them yours.
clc;clear all;close all;
% creating a colored plane image programatically
disp('Create a plane image of any color');
disp('Enter R,G,B plane values - between 0-255');
R = input('Enter RED plane value\n');
G = input('Enter GREEN plane value\n');
B = input('Enter BLUE plane value\n');
a = ones([500 500 3]);
new = a;
for plane = 1:3
for i = 1:size(a,1)
for j= 1:size(a,2)
if plane == 1
new(i,j,plane) = R;
elseif plane == 2
new(i,j,plane) = G;
elseif plane == 3
new(i,j,plane) = B;
end
end
end
end
new = uint8(new);
figure;imshow(new);
whos new
In GUI:
axes(handles.axes1);imshow(new);
axes(handles.axes2);imshow(new);
Initialize axes to the same color as the body of the GUI.
Here is a code just for fun but may be useful to you somewhere (I used it in a GUI)
% creating a colored plane image programatically
disp('Create a plane image of any color');
disp('Enter R,G,B plane values - between 0-255');
R = input('Enter RED plane value\n');
G = input('Enter GREEN plane value\n');
B = input('Enter BLUE plane value\n');
a = ones([500 500 3]);
new = a;
for plane = 1:3
for i = 1:size(a,1)
for j= 1:size(a,2)
if plane == 1
new(i,j,plane) = R;
elseif plane == 2
new(i,j,plane) = G;
elseif plane == 3
new(i,j,plane) = B;
end
end
end
end
new = uint8(new);
figure;imshow(new);
whos new
In GUI:
axes(handles.axes1);imshow(new);
axes(handles.axes2);imshow(new);
Initialize axes to the same color as the body of the GUI.
No comments:
Post a Comment