Analysis Guide P2

20 ビュー (過去 30 日間)
Sergio Federer
Sergio Federer 2022 年 12 月 7 日
回答済み: Sergio Federer 2022 年 12 月 7 日
Guide tarefa 2 (sub)
function pushbutton1_Callback(hObject, eventdata, handles)
% 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)
global a
a=imread(uigetfile('*.jpg;*.png;*.bitmap'));
imshow(a);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global a
global A
A = rgb2gray (a);
imhist(A)
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global A
g = histeq (A);
imshow (g)
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global A
bw=im2bw (A);
imshow(bw)
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global A
neg=imcomplement(A);
imshow(neg)

採用された回答

Sergio Federer
Sergio Federer 2022 年 12 月 7 日
編集済み: Sergio Federer 2022 年 12 月 7 日
Tarefa 3
Crie um GUIDE com as seguintes funções: - Um botão para abrir uma imagem
- Abra a imagem contaminada com ruído;
- Um botão que aplique um filtro de mediana e tenha opção de selecionar as seguintes máscaras: 3x3 5x5 7x7 - Comente os resultados ao utilizar os diferentes tamanhos de máscaras na imagem contaminada.
- Um botão para aplicar o filtro de Gauss na imagem contaminada;
function pushbutton1_Callback(hObject, eventdata, handles)
% 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)
global img
img = imread(uigetfile('*.jpg;*.png;*.bitmap'));
axes(handles.axes1);
imshow(img);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global img cinza
cinza = rgb2gray(img);
axes(handles.axes2);
imshow(cinza);
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global cinza
axes(handles.axes3);
b = medfilt2(cinza,[3 3])
imshow(b); title ('Filtro mediana 3x3');
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global cinza
axes(handles.axes3);
c = medfilt2(cinza,[5 5])
imshow(c);title ('Filtro mediana 5x5');
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global cinza
axes(handles.axes3);
d = medfilt2(cinza,[7 7])
imshow(d);title ('Filtro mediana 7x7');
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global cinza
GAU = get(handles.popupmenu1,'Value');
switch GAU
case 2
g = imgaussfilt(cinza,2);
axes(handles.axes3);
imshow(g);title ('Filtro Gaussiano');
end
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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

その他の回答 (2 件)

Sergio Federer
Sergio Federer 2022 年 12 月 7 日
Tarefa 4
Crie um GUIDE com as seguintes funções:
- Um botão para abrir uma imagem;
- Um botão para adicionar o ruído sal e pimenta, utilizando a função imnoise;
- Um botão que aplique o filtro de mediana da tarefa anterior na imagem com o ruído sala e pimenta utilizando as máscaras de 3x3 e 7x7.
function pushbutton1_Callback(hObject, eventdata, handles)
% 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)
global c;
c = imread(uigetfile('*.jpg;*.png;*.bitmap'));
axes(handles.axes2);
imshow(c);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global gray
J = imnoise(gray,'salt & pepper',0.5);
K = medfilt2(J,[3 3]);
axes(handles.axes4)
imshow(K)
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global gray
J = imnoise(gray,'salt & pepper',0.5);
axes(handles.axes7)
imshow(J)
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global c
global gray
gray=rgb2gray(c);
axes(handles.axes3);
imshow(gray);
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global gray
J = imnoise(gray,'salt & pepper',0.5);
M = medfilt2(J,[7 7]);
axes(handles.axes5)
imshow(M)

Sergio Federer
Sergio Federer 2022 年 12 月 7 日
Compressão Livre de Erro
Algoritmo de Huffman: probabilidade de pixels em cada posição
Compressão com perdas
Codificação por transformada: JPEG → compressão c perda, mais famoso, acaba perdendo
qualidade (elimina componentes de alta frequência).
Processamento Morfológico
Existem dois operadores morfológicos: dilatação e erosão.
Imagens binárias: primeiro plano, segundo plano e conectividade Imagem binária: pixel 1→
primeiro plano; pixel 0: segundo plano Imagem binária: não tem informação de textura
(escala de cinza, apenas). Forma, tamanho e localização. As modificações serão transformar
um pixel preto em branco e branco em preto (Pixels de 1o plano → 2o plano; Pixels de 2o
plano → 1o plano).
Erosão: Elemento de primeiro plano: reduziram de tamanho do tamanho original, pega um
pixel de primeiro plano e transforma em segundo plano (“Afina os objetos”).
Reduz o tamanho de um objeto binário; remove pequenas características isoladas; separa
regiões adjuntas delgadas.
Dilatação: “Engrossa os objetos”
aumenta o tamanho de um objeto binário; ressalta características em torno de bordas; alarga
regiões estreitas
Dilatação e Erosão
bw = imread('text.png'); %imagem binária
se=[0 1 0; 1 1 1; 0 1 0]; %define elemento estrutural
bw_out=imdilate(bw,se); %dilata a imagem
subplot(1,2,1), imshow(bw); %exibe a original
subplot(1,2,2), imshow(bw_out); %exibe imagem dilatada
Gerando matriz de 1 com 6 linhas
bw = imread('text.png'); %imagem binária
se=ones(6,1); %define elemento estrutural
bw_out=imerode(bw,se); %erode a imagem
subplot(1,2,1), imshow(bw); %exibe o original
subplot(1,2,2), imshow(bw_out); %exibe imagem erodida
bw = imread('text.png');%imagem binária
se1 = strel('square',4) %quadrado 4 por 4
se2 = strel('line',5,45) %reta, comprimento 5, angulo 45 graus
bw_1=imdilate(bw,se1); %dilata a imagem
bw_2=imerode(bw,se2); %erode a imagem
subplot(1,2,1), imshow(bw_1); %exibe imagem dilatada
subplot(1,2,2), imshow(bw_2); %exibe imagem erodida
length=18;tlevel=0.2; %define elemento estrutural e nível percentual de limiar
A=imread('circuit.tif');subplot(2,3,1),imshow(A) %lê a imagem e exibe
B=im2bw(A,tlevel);subplot(2,3,2),imshow(~B); %aplica limiar à imagem e a exibe
SE=ones(3,length);bw1=imerode(~B,SE); %erode retas verticais
subplot(2,3,3),imshow(bw1); %exibe resultado
bw2=imerode(bw1,SE');subplot(2,3,4),imshow(bw2); %erode retas horizontais
bw3=imdilate(bw2,SE');bw4=imdilate(bw3,SE); %dilata
subplot(2,3,5),imshow(bw4); %exibe resultado
boundary=bwperim(bw4);[i,j]=find(boundary); %sobrepõe fronteiras
subplot(2,3,6),imshow(A);hold on;plot(j,i,'r.');

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by