Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rafael committed Oct 23, 2020
0 parents commit 95032c2
Show file tree
Hide file tree
Showing 19 changed files with 2,706 additions and 0 deletions.
Binary file added LDC2006S16.wav
Binary file not shown.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# pdscodes

Code snippets and notebooks used in PDS classes.

All (almost) codes are in Python3 language.

---

## Sampling and quantization
- [quantization](https://github.com/rsmarinho/pdscodes/blob/master/quantization.py): 1d signal quantization examples
- [quantization2](https://github.com/rsmarinho/pdscodes/blob/master/quantization2.py): 2d signal quantization examples
- [nyquist](https://github.com/rsmarinho/pdscodes/blob/master/nyquist.py): Shannon-Nyquist Sampling Theorem examples

## Signals and operations
- [impulse](https://github.com/rsmarinho/pdscodes/blob/master/impulse.py): Impulse signal examples
- [step](https://github.com/rsmarinho/pdscodes/blob/master/step.py): Step signal examples
- [operations](https://github.com/rsmarinho/pdscodes/blob/master/operations.py): Signal operations examples
- [convolution](https://github.com/rsmarinho/pdscodes/blob/master/convolution.py): Convolution function example

## Discrete Fourier
- [dft](https://github.com/rsmarinho/pdscodes/blob/master/dft.ipynb) (jupyter notebook): Discrete Fourier Transform notebook
- [fft](https://github.com/rsmarinho/pdscodes/blob/master/fft.ipynb) (jupyter notebook): Fast Fourier Transform notebook

## Homework (Trabalhos Práticos)
All home works are jupyter notebooks. These files can be opened using google-colab.

- [TP01](https://github.com/rsmarinho/pdscodes/blob/master/TP01.ipynb)
- [TP02](https://github.com/rsmarinho/pdscodes/blob/master/TP02.ipynb)
- [TP04](https://github.com/rsmarinho/pdscodes/blob/master/TP04.ipynb)
- [TP05](https://github.com/rsmarinho/pdscodes/blob/master/TP05.ipynb)

---

## Auxiliary files
- [arroz e feijao](https://github.com/rsmarinho/pdscodes/blob/master/LDC2006S16.wav): Audio wave file used in some examples (SPOLTECH audio file)
- [barbara](https://github.com/rsmarinho/pdscodes/blob/master/LDC2006S16.wav): Image (png) file used in some examples
- [paganini](https://github.com/rsmarinho/pdscodes/blob/master/LDC2006S16.wav): Audio wave file used in some examples (from wikimedia)
- [table notes](https://github.com/rsmarinho/pdscodes/blob/master/notas_musicais.jpg): Image containing the frequencies of musical tones. Don't know the author.
193 changes: 193 additions & 0 deletions TP01.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "TP01.ipynb",
"provenance": [],
"collapsed_sections": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/rsmarinho/pdscodes/blob/master/TP01.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "GqOc8H84dZHV",
"colab_type": "code",
"colab": {}
},
"source": [
"# here goes your include modules...\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "QIVQHZMBda6I",
"colab_type": "text"
},
"source": [
"**TP01 - Convolução Linear em duas dimensões.**\n",
"\n",
"---\n",
"\n",
"A convolução linear é a operação linear em que um sistema LIT quando estimulado por um sinal qualquer $x[n]$, tem sua resposta dada por $$y[n]=\\sum_{n=0}^\\infty x[k]h[n-k]$$\n",
"\n",
"No caso de o sinal de estímulo ter mais de uma dimensão (duas por exemplo), é preciso que o sistema tenha o mesmo número de dimensões. Nesse caso a convolução terá resposta dada por $$y[n,m]=\\sum_{n=m=0}^\\infty x[k,l]h[n-k,m-l]$$\n",
"\n",
"Com essas informações, responda às seguintes questões:"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "y2gBvT4Fhplr",
"colab_type": "text"
},
"source": [
"**1.** Crie uma função de convolução linear bidimensional na forma definida abaixo. A variável ans deve retornar o resultado da convolução."
]
},
{
"cell_type": "code",
"metadata": {
"id": "QMmrvsK-hqJA",
"colab_type": "code",
"colab": {}
},
"source": [
"def conv2d(M, img):\n",
" # code goes here...\n",
"\n",
" return ans"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "-DHg9Lk9gDPx",
"colab_type": "text"
},
"source": [
"**2.** Suponha que um sistema linear é definido por uma matriz $M$ de tamanho 3x3. Essa matriz deve ser criada de acordo com as nove primeiras letras de seu nome (a=1, b=2, c=3, ...). Proceda com a convolução linear entre a matriz $M$ e a imagem [barbara.jpg](https://github.com/rsmarinho/pdscodes/blob/master/barbara.png)."
]
},
{
"cell_type": "code",
"metadata": {
"id": "j5XBGYGalpQP",
"colab_type": "code",
"colab": {}
},
"source": [
""
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "kHA7wnMnlpum",
"colab_type": "text"
},
"source": [
"**3.** Utilize as seguintes matrizes como função de transferência do sistema e execute seu código para cada uma delas."
]
},
{
"cell_type": "code",
"metadata": {
"id": "khvLFiIbl32F",
"colab_type": "code",
"colab": {}
},
"source": [
"h1 = np.array([[1.96412803e-05, 1.76805171e-03, 1.96412803e-05], \n",
" [1.76805171e-03, 1.59154943e-01, 1.76805171e-03], \n",
" [1.96412803e-05, 1.76805171e-03, 1.96412803e-05]])"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "ucbRT8bDl-TE",
"colab_type": "code",
"colab": {}
},
"source": [
"h2 = np.array([[1.96412803e-05, 5.74002351e-04, 1.76805171e-03, 5.74002351e-04, 1.96412803e-05], \n",
" [5.74002351e-04, 1.67748076e-02, 5.16700450e-02, 1.67748076e-02, 5.74002351e-04], \n",
" [1.76805171e-03, 5.16700450e-02, 1.59154943e-01, 5.16700450e-02, 1.76805171e-03], \n",
" [5.74002351e-04, 1.67748076e-02, 5.16700450e-02, 1.67748076e-02, 5.74002351e-04], \n",
" [1.96412803e-05, 5.74002351e-04, 1.76805171e-03, 5.74002351e-04, 1.96412803e-05]])"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "bLvTRIkWmcWm",
"colab_type": "code",
"colab": {}
},
"source": [
"h3 = np.array([[1.96412803e-05, 2.39279779e-04, 1.07237757e-03, 1.76805171e-03, 1.07237757e-03, 2.39279779e-04, 1.96412803e-05],\n",
" [2.39279779e-04, 2.91502447e-03, 1.30642333e-02, 2.15392793e-02, 1.30642333e-02, 2.91502447e-03, 2.39279779e-04],\n",
" [1.07237757e-03, 1.30642333e-02, 5.85498315e-02, 9.65323526e-02, 5.85498315e-02, 1.30642333e-02, 1.07237757e-03],\n",
" [1.76805171e-03, 2.15392793e-02, 9.65323526e-02, 1.59154943e-01, 9.65323526e-02, 2.15392793e-02, 1.76805171e-03],\n",
" [1.07237757e-03, 1.30642333e-02, 5.85498315e-02, 9.65323526e-02, 5.85498315e-02, 1.30642333e-02, 1.07237757e-03],\n",
" [2.39279779e-04, 2.91502447e-03, 1.30642333e-02, 2.15392793e-02, 1.30642333e-02, 2.91502447e-03, 2.39279779e-04],\n",
" [1.96412803e-05, 2.39279779e-04, 1.07237757e-03, 1.76805171e-03, 1.07237757e-03, 2.39279779e-04, 1.96412803e-05]])"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "KYvjj3YwnHZw",
"colab_type": "text"
},
"source": [
"Após rodar seu código explique quais suas impressões sobre as imagens (processadas e não-processada), o que você achou de diferente e qual sua interpretação do processamento que o filtro faz."
]
},
{
"cell_type": "code",
"metadata": {
"id": "qUVJfGVkkyII",
"colab_type": "code",
"colab": {}
},
"source": [
""
],
"execution_count": null,
"outputs": []
}
]
}
Loading

0 comments on commit 95032c2

Please sign in to comment.