Построение графического интерфейса в системе Matlab

Автор работы: Пользователь скрыл имя, 21 Ноября 2012 в 21:44, реферат

Краткое описание

Matlab – это система инженерных и научных вычислений. Она обеспечивает математические вычисления, визуализацию научной графики программирование и моделирование процессов с использованием интуитивно понятной среды окружения, когда задачи и их решения могут быть представлены в нотации, близкой к математической.

Содержимое работы - 1 файл

самост ЦОИ.doc

— 475.00 Кб (Скачать файл)

% hObject    handle to editContrast (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

 

% Hint: edit controls usually have a white background on Windows.

%       See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

    set(hObject,'BackgroundColor','white');

end

 

 

 

 

% --- Executes on button press in pushbuttonContrastBrightness.

function pushbuttonContrastBrightness_Callback(hObject, eventdata, handles)

% hObject    handle to pushbuttonContrastBrightness (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

if (handles.fileLoaded==1)

    handles.RGB2 = changeBrightness(handles.RGB, get(handles.sliderBright, 'Value'), get(handles.sliderContrast, 'Value'));

    axes(handles.axes2); imshow(handles.RGB2);

    handles.fileLoaded2 = 1;

    handles = updateHistograms(handles);

    guidata(hObject, handles);

else

    h = msgbox('No primary file has been loaded!','Error','error');

end

 

 

function handlesNew = updateHistograms(handles)

handlesNew = handles;

if (handles.fileLoaded == 1)

    set(handles.textHist1, 'Visible', 'on');

    axes(handlesNew.axesHist1);

    cla;

    ImageData1 = reshape(handlesNew.RGB(:,:,1), [size(handlesNew.RGB, 1) * size(handlesNew.RGB, 2) 1]);

    ImageData2 = reshape(handlesNew.RGB(:,:,2), [size(handlesNew.RGB, 1) * size(handlesNew.RGB, 2) 1]);

    ImageData3 = reshape(handlesNew.RGB(:,:,3), [size(handlesNew.RGB, 1) * size(handlesNew.RGB, 2) 1]);

    [H1, X1] = hist(ImageData1, 1:5:256);

    [H2, X2] = hist(ImageData2, 1:5:256);

    [H3, X3] = hist(ImageData3, 1:5:256);

    hold on;

    plot(X1, H1, 'r');

    plot(X2, H2, 'g');

    plot(X3, H3, 'b');   

    axis([0 256 0 max([H1 H2 H3])]);

end

if (handlesNew.fileLoaded2 == 1)

    set(handles.textHist2, 'Visible', 'on');

    axes(handlesNew.axesHist2);

    cla;

    ImageData1 = reshape(handlesNew.RGB2(:,:,1), [size(handlesNew.RGB2, 1) * size(handlesNew.RGB2, 2) 1]);

    ImageData2 = reshape(handlesNew.RGB2(:,:,2), [size(handlesNew.RGB2, 1) * size(handlesNew.RGB2, 2) 1]);

    ImageData3 = reshape(handlesNew.RGB2(:,:,3), [size(handlesNew.RGB2, 1) * size(handlesNew.RGB2, 2) 1]);

    [H1, X1] = hist(ImageData1, 1:5:256);

    [H2, X2] = hist(ImageData2, 1:5:256);

    [H3, X3] = hist(ImageData3, 1:5:256);

    hold on;

    plot(X1, H1, 'r');

    plot(X2, H2, 'g');

    plot(X3, H3, 'b');   

    axis([0 256 0 max([H1 H2 H3])]);   

end

 

 

 

% --- Executes on button press in RotateButton.

function RotateButton_Callback(hObject, eventdata, handles)

% hObject    handle to RotateButton (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

 

handles.RGB2 = imrotate(handles.RGB, round(get(handles.sliderRotate,'Value')));

handles.fileLoaded = 1;

 

axes(handles.axes2); cla; imshow(handles.RGB2);

 

handles = updateHistograms(handles);

 

guidata(hObject, handles);

 

 

 

% --- Executes on slider movement.

function sliderRotate_Callback(hObject, eventdata, handles)

% hObject    handle to sliderRotate (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

 

% Hints: get(hObject,'Value') returns position of slider

%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

set(handles.editRotate,'String', sprintf('%10s:%4.0f', 'Rotate', round(get(handles.sliderRotate,'Value'))));

 

% --- Executes during object creation, after setting all properties.

function sliderRotate_CreateFcn(hObject, eventdata, handles)

% hObject    handle to sliderRotate (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

 

% Hint: slider controls usually have a light gray background.

if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

    set(hObject,'BackgroundColor',[.9 .9 .9]);

end

 

 

 

function editRotate_Callback(hObject, eventdata, handles)

% hObject    handle to editRotate (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

 

% Hints: get(hObject,'String') returns contents of editRotate as text

%        str2double(get(hObject,'String')) returns contents of editRotate as a double

 

 

% --- Executes during object creation, after setting all properties.

function editRotate_CreateFcn(hObject, eventdata, handles)

% hObject    handle to editRotate (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

 

% Hint: edit controls usually have a white background on Windows.

%       See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

    set(hObject,'BackgroundColor','white');

end

 

 


Информация о работе Построение графического интерфейса в системе Matlab