FIC MATLAB 2017-1/Aula-12

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
%-- 05-04-2017 19:07:55 --%
clc
x = 0:0.01:4*pi
4*pi
y = cos(x)
plot(x, y)
hold on
z = sin(x);
stem(x, z)
x
x(1:50:end)
z(1:50:end)
hold off
hold on
subplot(2,1,2)
stem(x(1:50:end), z(1:50:end))
hold on
plot(x, z, 'r')
bars(x(1:100:end), z(1:100:end))
bar(x(1:100:end), z(1:100:end))
z(1)
clear all
x = 0:8
y = x.^2
plot(x, y)
grid on
hold on
stairs(x, y)
clc
clear
x = 1 : 0.1 : 1000;
y = 1 / (1 + x^2)
y = 1 / (1 + x.^2)
y = 1 ./ (1 + x.^2);
subplot(2,2,1)
plot(x,y)
grid on
subplot(2,2,2)
semilogx(x, y)
grid on
subplot(2,2,3)
semilogy(x, y)
grid
subplot(2,2,4)
loglog(x, y)
grid on
loglog(x, y, 'bo')
x = 1 : 1 : 1000;
y = 1 ./ (1 + x.^2);
loglog(x, y, 'bo')
x = logspace(0, 3, 1000);
y = 1 ./ (1 + x.^2);
loglog(x, y, 'bo')
x = 1 : 1 : 50;
y = 1 ./ (1 + x.^2);
loglog(x, y, 'bo')
x = logspace(0, 3, 50);
y = 1 ./ (1 + x.^2);
loglog(x, y, 'bo')
rad2deg(pi/6)
lookfor degree
rad2deg(pi/6)
convert2deg (pi/6)
t = 0:0.01:6*pi;
r = linspace(1, 0, length(t));
help polar
polar(t, r)
figura
figure
plot(t, r)
r = logspace(1, 0, length(t));
polar(t, r)
figure
plot(t, r)
clc
x = linspace(0, 4*pi, 1000);
y = 2*sin(x);
z = 30*cos(2*x);
plotyy(x, y, x, z)
legend('tensao (V)', 'corrente (mA)')
doc plotyy
help comet
doc comet
t = 0:.01:2*pi;
x = cos(2*t).*(cos(t).^2);
y = sin(2*t).*(sin(t).^2);
comet(x,y);
clc
% Plots em 3D
t = 0:0.1:10*pi;
x = cos(t);
y = sin(t);
z = t;
figure
plot3(x,y,z)
grid on
xlabel('x'); ylabel('y'); zlabel('z')
view(-90,0)
view(0,0)
% Grade 3D
[X,Y] = meshgrid(-5:5);
x = -5:5;
y = 0:4;
x
y
clc
x = -5:5
y = 0:4
[X,Y] = meshgrid(x,y)
[X,Y] = meshgrid(x)
[X,Y] = meshgrid(-20:0.5:20);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
mesh(X,Y,Z)
eps
surf(X,Y,Z)
shading flat
shading faceted
shading interp
shading flat
shading interp
surfc(X,Y,Z)
contour(X,Y,Z)
surfc(X,Y,Z)
meshc(X,Y,Z)
surfc(X,Y,Z)
shading interp
meshz(X,Y,Z)
waterfall(X,Y,Z)
%-- 12-04-2017 19:07:50 --%
clc
% Aula 12
ls
% Lendo a imagem
doc imread
x = imread('imagem1.jpeg');
size(x)
max(max(x))
599*507
figure
imshow(x)
0.1059*255
whos x
whos ans
y = 255 - x
z = x - 255;
max(z)
var1 = uint8(9)
var1 - 15
% Negativo da imagem
y = 255 - x;
figure
imshow(y)
title('Negativo da imagem')
% Aumentando o brilho
z = x + 50;
figure
imshow(z)
z = x + 150;
imshow(z)
uint8(1.9)
uint8(1.1)
0.2 * 255
w = uint8(51 + (204/255)*double(x));
figure
imshow(w)
z = x + 51;
imshow(z)
% Aumentar e reduzir o contraste
limiar = 180;
a = double(x)/limiar;
max(max(a))
255/180
b = a .^ 2;
max(max(b))
c = b * limiar;
max(max(c))
d = uint8(c);
figure
subplot(1,2,1); imshow(x); title('Imagem original')
subplot(1,2,2); imshow(d); title('Contraste aumentado')
% Aplicando contraste a somente uma parte
e = x;
figure
imshow(e(309:end,243:end))
e(309:end,243:end) = e(309:end,243:end) + 100;
figure
imshow(e)
% Binarização
f = (x >= limiar);
figure
imshow(f)
% Marca d'água
marca = imread('logo.gif');
figure
imshow(marca)
marca0_1 = double(marca)/double(max(max(marca)));
figure
surf(marca0_1)
camada = ones(size(x));
size(marca0_1,1)
size(marca0_1,2)
camada(1:139, 1:102) = marca0_1;
figure
imshow(camada)
g = uint8(double(x) .* camada);
figure
imshow(g)
% Imagem colorida
clear all; close all;
a = imread('imagem2.jpeg');
figure
imshow(a)
z = a(1:3,1:3,1:3);
z(:,:,1)
z(:,:,2)
z(:,:,3)
max(max(max(a)))
max(max(a(:,:,1)))
max(max(a(:,:,2)))
max(max(a(:,:,3)))
y = a(:,:,1) == 255;
figure
imshow(y)
y2 = a(:,:,2) == 255;
imshow(y2)
y = (a(:,:,1) == 255) & (a(:,:,2) == 255) & (a(:,:,3) == 255);
max(max(y))
y = (a(:,:,1) == 255) & (a(:,:,2) == 255);
max(max(y))
y = (a(:,:,1) == 255) & (a(:,:,3) == 255);
max(max(y))
[m,n] = max(max(y))
[m,n,o] = max(max(y))
[m,n] = max(max(y))
[m,n] = max(max(y'))
[m,n] = ind2sub(y,157)
max(y)
y = (a(:,:,1) == 255) & (a(:,:,3) == 255);
y
max(max(y))
find(y)
ind2sub(y, 93776)
[m, n] = ind2sub(y, 93776)
figure
imshow(x)
x = imread('imagem1.jpeg');
imshow(x)
[r, x] = find(y)