I have 5 checkbox that represent 5 types of noise which is salt&pepper noise,localvar noise,gaussian noise, speckle noise and poisson noise. i want the user to be able to select multiple noise which is double noise or triple noise by clicking the checkbox and the noises will apply to the image.and after user click the checkboxes at the top of the image, it will show title of the combine noises.for example, title('poisson noise and speckle noise'). and also when the user uncheck the checkbox the noise is dissapear from the image. So here my current coding:
function pushbutton1_Callback(hObject, eventdata, handles)[filename, pathname] = uigetfile({'*.jpg';'*.tif';'*.png'},'Select File');if isequal(filename,0)|| isequal(pathname,0) uiwait(msgbox ('User pressed cancel','please select an image') ) hold on;else uiwait(msgbox('User selected image sucessfully','sucess')); hold off; img = imread([pathname filename]); img = img(:,:,1); axes(handles.axes1); imshow(img); title('original image'); %update the handles structure with the image
handles.imgData = img; %save the handles data
guidata(hObject,handles) end%check to make sure that the image data exists in handles
if isfield(handles,'imgData') %grab the image data from handles
I = handles.imgData; axes(handles.axes2); imshow(img);end% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)isChecked = get(hObject,'Value');if isChecked==1if isfield(handles,'imgData') %grab the image data from handles I = handles.imgData; J = imnoise(I,'salt & pepper',0.3); axes(handles.axes2); imshow(J); title('Noise type: Salt & pepper');endguidata(hObject, handles)end % hObject handle to checkbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of checkbox1
% --- Executes on button press in checkbox2.
function checkbox2_Callback(hObject, eventdata, handles)isChecked = get(hObject,'Value');if isChecked==1if isfield(handles,'imgData') %grab the image data from handles I = handles.imgData; M = imnoise(I,'gaussian',0.1,0.1); axes(handles.axes2); imshow(M); title('Noise type: Gaussian noise');endguidata(hObject, handles)end % hObject handle to checkbox2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of checkbox2
% --- Executes on button press in checkbox3.
function checkbox3_Callback(hObject, eventdata, handles)isChecked = get(hObject,'Value');if isChecked==1if isfield(handles,'imgData') %grab the image data from handles I = handles.imgData; N=imnoise(I,'localvar',0.05*rand(size(I))); axes(handles.axes2); imshow(N); title('Noise type: Localvar noise');endguidata(hObject, handles)end % hObject handle to checkbox3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of checkbox3
% --- Executes on button press in checkbox4.
function checkbox4_Callback(hObject, eventdata, handles)isChecked = get(hObject,'Value');if isChecked==1if isfield(handles,'imgData') %grab the image data from handles I = handles.imgData; P=imnoise(I,'poisson'); axes(handles.axes2); imshow(P); title('Noise type: Poisson noise');endguidata(hObject, handles)end % hObject handle to checkbox4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of checkbox4
% --- Executes on button press in checkbox5.
function checkbox5_Callback(hObject, eventdata, handles)isChecked = get(hObject,'Value');if isChecked==1if isfield(handles,'imgData') %grab the image data from handles I = handles.imgData; Q = imnoise(I,'speckle', 0.3); axes(handles.axes2); imshow(Q); title('Noise type: Speckle noise');endguidata(hObject, handles)end % hObject handle to checkbox5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of checkbox5
Best Answer