1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
function main
%----------------------------------------------------------
%
%GENERAL STRUCTURE
%
%----------------------------------------------------------
%create a figure
handles.figure = figure('Units', 'Pixels',...
'Position', [100 100 1024 768],...
'Numbertitle', 'off',...
'Name', 'POLSAR reader',...
'Menubar', 'none',...
'visible', 'on');
%----------------------------------------------------------
%
%INPUT STUPID PICTURE TO TEST THE FUNCTIONS
%
%----------------------------------------------------------
%handles.input_image = imread('coupons.jpg');
%[M, N, C] = size(handles.input_image);
%----------------------------------------------------------
%
%OPEN
%
%----------------------------------------------------------
%create button to open a picture
handles.buttonOpen = uicontrol('Style', 'pushbutton',...
'Units', 'Pixels', ...
'Position', [25 730 75 25],...
'String', 'Open');
%----------------------------------------------------------
%
%CHOICE OF CHANNELS TO DISPLAY
%
%----------------------------------------------------------
%create button choice of RWB vs BnW
handles.buttonRGBorBnW = uicontrol('Style', 'togglebutton',...
'Units', 'Pixels', ...
'Position', [25 695 75 25],...
'String', 'RGB or B&W ?');
%create panel choice of RGB vs BnW
handles.panelRGBorBnW = uipanel('Units', 'Pixels', ...
'Backgroundcolor', [1 1 1],...
'Foregroundcolor', [0 0 0],...
'Title', 'RGB or B&W ?',...
'Position', [50 225 175 250],...
'Visible', 'off');
%choice of RGB vs BW
%SECTION CUT
handles.radioBnW = uicontrol('Style', 'radiobutton',...
'Parent', handles.panelRGBorBnW,...
'String', 'BnW',...
'Position', [100 210 50 15],...
'HandleVisibility', 'on');
%create panel BnW
handles.panelBnW = uipanel('Units', 'Pixels', ...
'Parent', handles.panelRGBorBnW,...
'Backgroundcolor', [1 1 1],...
'Foregroundcolor', [0 0 0],...
'Title', 'BnW panel', ...
'Position', [7 0 160 190]);
%content of panel BnW
handles.radioBnWCh1 = uicontrol('Style', 'radiobutton',...
'String', 'Channel 1',...
'Position', [10 115 75 25],...
'HandleVisibility', 'on',...
'Parent', handles.panelBnW);
handles.radioBnWCh2 = uicontrol('Style', 'radiobutton',...
'String', 'Channel 2',...
'Position', [10 90 75 25],...
'HandleVisibility', 'on',...
'Parent', handles.panelBnW);
handles.radioBnWCh3 = uicontrol('Style', 'radiobutton',...
'String', 'Channel 3',...
'Position', [10 65 75 25],...
'HandleVisibility', 'on',...
'Parent', handles.panelBnW);
%----------------------------------------------------------
%
%SET
%
%----------------------------------------------------------
set(handles.buttonOpen, 'callback', {@buttonOpen_callback, handles});
set(handles.buttonRGBorBnW, 'callback', {@buttonRGBorBnW_callback, handles});
set(handles.radioBnW, 'callback', {@radioRGBorBnW_callback, handles, 2});
set(handles.radioBnWCh1, 'callback', {@radioBnWchoice_callback, handles, 1});
set(handles.radioBnWCh2, 'callback', {@radioBnWchoice_callback, handles, 2});
set(handles.radioBnWCh3, 'callback', {@radioBnWchoice_callback, handles, 3});
%----------------------------------------------------------
%
%GUIDATA
%
%----------------------------------------------------------
data = guidata(gcf);
guidata(gcf, data);
%----------------------------------------------------------
%
%CALLBACK FUNCTIONS
%
%----------------------------------------------------------
%callback functions for the Open Button
function buttonOpen_callback(hObject, event_data, handles)
data = guidata(gcbf);
[FileName, PathName] = uigetfile('*.jpg','Select the image file');
handles.input_image = imread(fullfile(PathName, FileName));
guidata(gcbf, data);
%callback functions RGB or BnW
function buttonRGBorBnW_callback(hObject, event_data, handles)
data = guidata(gcbf);
if get(handles.buttonRGBorBnW, 'Value')
set(handles.panelRGBorBnW, 'Visible', 'on');
if get(handles.radioBnW, 'Value')
set(handles.panelBnW, 'Visible', 'on');
else
set(handles.panelBnW, 'Visible', 'off');
end
else
set(handles.panelRGBorBnW, 'Visible', 'off');
end
guidata(gcbf, data);
function radioRGBorBnW_callback(gcf, event_data, handles, radio_value)
data = guidata(gcbf);
switch radio_value
case 2 %BnW
set(handles.radioBnW, 'Value', 1);
set(handles.panelBnW, 'Visible', 'on');
end
guidata(gcbf, data);
function radioBnWchoice_callback(gcf, event_data, handles, radio_value)
data = guidata(gcbf);
switch radio_value
case 1 %channel 1
set(handles.radioBnWCh1, 'Value', 1);
set(handles.radioBnWCh2, 'Value', 0);
set(handles.radioBnWCh3, 'Value', 0);
handles.display_image = handles.input_image(:,:,1);
imshow(handles.display_image);
guidata(gcbf, data);
case 2 %channel 2
set(handles.radioBnWCh1, 'Value', 0);
set(handles.radioBnWCh2, 'Value', 1);
set(handles.radioBnWCh3, 'Value', 0);
handles.display_image = handles.input_image(:,:,2);
imshow(handles.display_image);
guidata(gcbf, data);
case 3 %channel 3
set(handles.radioBnWCh1, 'Value', 0);
set(handles.radioBnWCh2, 'Value', 0);
set(handles.radioBnWCh3, 'Value', 1);
handles.display_image = handles.input_image(:,:,3);
imshow(handles.display_image);
guidata(gcbf, data);
end |
Partager