Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Proyecto_Datos
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jennifer Lorena Ortega Aguilar
Proyecto_Datos
Commits
f401b85a
Commit
f401b85a
authored
4 years ago
by
Carla Elena Gomez Alvarado
Browse files
Options
Downloads
Patches
Plain Diff
Update revision path llamado de imagenes. Procesamiento_digital_imagenes_bordes.ipynb
parent
9f999031
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Procesamiento_digital_imagenes_bordes.ipynb
+4
-4
4 additions, 4 deletions
Procesamiento_digital_imagenes_bordes.ipynb
with
4 additions
and
4 deletions
Procesamiento_digital_imagenes_bordes.ipynb
+
4
−
4
View file @
f401b85a
...
@@ -22,10 +22,10 @@
...
@@ -22,10 +22,10 @@
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"#imagename = \"Data/crateres.jpg\"\n",
"#imagename = \"Data
_Mars
/crateres.jpg\"\n",
"#imagename = \"Data/Perseverance_ZR0_0074.png\" -codigo adicional para recorte de bordes negros.\n",
"#imagename = \"Data
_Mars
/Perseverance_ZR0_0074.png\" -codigo adicional para recorte de bordes negros.\n",
"#imagename = \"Data/mastcamz_2_prints.jpg\"\n",
"#imagename = \"Data
_Mars
/mastcamz_2_prints.jpg\"\n",
"imagename = \"Data/Data_Mars_Mars8.png\"\n",
"imagename = \"Data
_Mars
/Data_Mars_Mars8.png\"\n",
" \n",
" \n",
"# read the image data using PIL\n",
"# read the image data using PIL\n",
"image = Image.open(imagename)"
"image = Image.open(imagename)"
...
...
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
cv2
import
cv2
import
numpy
as
np
import
numpy
as
np
from
matplotlib
import
pyplot
as
plt
from
matplotlib
import
pyplot
as
plt
from
PIL
import
Image
from
PIL
import
Image
from
PIL.ExifTags
import
TAGS
from
PIL.ExifTags
import
TAGS
from
numpy
import
asarray
from
numpy
import
asarray
from
numpy.fft
import
fft2
,
fftshift
,
fftfreq
,
ifft2
#Python DFT
from
numpy.fft
import
fft2
,
fftshift
,
fftfreq
,
ifft2
#Python DFT
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
#imagename = "Data/crateres.jpg"
#imagename = "Data
_Mars
/crateres.jpg"
#imagename = "Data/Perseverance_ZR0_0074.png" -codigo adicional para recorte de bordes negros.
#imagename = "Data
_Mars
/Perseverance_ZR0_0074.png" -codigo adicional para recorte de bordes negros.
#imagename = "Data/mastcamz_2_prints.jpg"
#imagename = "Data
_Mars
/mastcamz_2_prints.jpg"
imagename
=
"
Data/Data_Mars_Mars8.png
"
imagename
=
"
Data
_Mars
/Data_Mars_Mars8.png
"
# read the image data using PIL
# read the image data using PIL
image
=
Image
.
open
(
imagename
)
image
=
Image
.
open
(
imagename
)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
display
(
image
)
display
(
image
)
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
crateres.jpg : Image downloaded from : https://mars.nasa.gov/mars2020-raw-images/pub/ods/surface/sol/00000/ids/edr/browse/edl/ELM_0000_0666952859_600ECM_N0000030LVS_04000_0000LUJ00_800.jpg
crateres.jpg : Image downloaded from : https://mars.nasa.gov/mars2020-raw-images/pub/ods/surface/sol/00000/ids/edr/browse/edl/ELM_0000_0666952859_600ECM_N0000030LVS_04000_0000LUJ00_800.jpg
Perseverance_ZR=_0074.png : Image downloaded from :
Perseverance_ZR=_0074.png : Image downloaded from :
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
img
=
cv2
.
imread
(
imagename
,
0
)
# load an image
img
=
cv2
.
imread
(
imagename
,
0
)
# load an image
#3 = np.asarray(imagename, dtype = np.float32) # Image class instance, I1, to float32 Numpy array, a
#3 = np.asarray(imagename, dtype = np.float32) # Image class instance, I1, to float32 Numpy array, a
img_float32
=
np
.
float32
(
img
)
img_float32
=
np
.
float32
(
img
)
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Para procesar la imagen se lee como cv2.imread y luego se le aplica la DFT
Para procesar la imagen se lee como cv2.imread y luego se le aplica la DFT
DFT: Discrete Fourier Transform.
DFT: Discrete Fourier Transform.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
hist
=
cv2
.
calcHist
([
img
],[
0
],
None
,[
256
],[
0
,
256
])
hist
=
cv2
.
calcHist
([
img
],[
0
],
None
,[
256
],[
0
,
256
])
plt
.
plot
(
hist
,
color
=
'
blue
'
)
plt
.
plot
(
hist
,
color
=
'
blue
'
)
plt
.
xlabel
(
'
Intensidad de Iluminacion
'
)
plt
.
xlabel
(
'
Intensidad de Iluminacion
'
)
plt
.
ylabel
(
'
Pixels Bins
'
)
plt
.
ylabel
(
'
Pixels Bins
'
)
plt
.
show
()
plt
.
show
()
plt
.
hist
(
np
.
concatenate
((
img
),
axis
=
0
),
bins
=
250
)
plt
.
hist
(
np
.
concatenate
((
img
),
axis
=
0
),
bins
=
250
)
plt
.
xlabel
(
'
Intensidad de Iluminacion
'
)
plt
.
xlabel
(
'
Intensidad de Iluminacion
'
)
plt
.
ylabel
(
'
Pixels Bins
'
)
plt
.
ylabel
(
'
Pixels Bins
'
)
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
#transform,ar el array de la imagen en punto flotante para ser procesado.
#transform,ar el array de la imagen en punto flotante para ser procesado.
dft
=
cv2
.
dft
(
np
.
float32
(
img
),
flags
=
cv2
.
DFT_COMPLEX_OUTPUT
)
dft
=
cv2
.
dft
(
np
.
float32
(
img
),
flags
=
cv2
.
DFT_COMPLEX_OUTPUT
)
dft_shift
=
np
.
fft
.
fftshift
(
dft
)
dft_shift
=
np
.
fft
.
fftshift
(
dft
)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
# convert image to numpy array
# convert image to numpy array
data
=
asarray
(
image
)
data
=
asarray
(
image
)
print
(
type
(
data
))
print
(
type
(
data
))
# caracteristicas de la imagen
# caracteristicas de la imagen
print
(
data
.
shape
)
print
(
data
.
shape
)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
#Muestra cada valor de cada pixel de la imagen como array en Numpy
#Muestra cada valor de cada pixel de la imagen como array en Numpy
#print(data)
#print(data)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
#imagen en el espacio de las frecuencias :
#imagen en el espacio de las frecuencias :
f
=
np
.
fft
.
fft2
(
img
)
#fft2 para 2 dimensiones
f
=
np
.
fft
.
fft2
(
img
)
#fft2 para 2 dimensiones
fshift
=
np
.
fft
.
fftshift
(
f
)
# para centrar las frecuencias bajas.
fshift
=
np
.
fft
.
fftshift
(
f
)
# para centrar las frecuencias bajas.
# fft2 tiene valors imaginarios por ello se saca el espectro real o de magnitud.
# fft2 tiene valors imaginarios por ello se saca el espectro real o de magnitud.
magnitude_sprectrum
=
20
*
np
.
log
(
np
.
abs
(
fshift
))
magnitude_sprectrum
=
20
*
np
.
log
(
np
.
abs
(
fshift
))
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
f
.
shape
f
.
shape
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
fft2
(
f
)
fft2
(
f
)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
#Matplotlib para crear 2 subplots en la misma linea para comparar la imagen original y
#Matplotlib para crear 2 subplots en la misma linea para comparar la imagen original y
#la imagen transformada en el espectro de frecuencias.
#la imagen transformada en el espectro de frecuencias.
plt
.
subplot
(
121
),
plt
.
imshow
(
img
,
cmap
=
'
gray
'
)
plt
.
subplot
(
121
),
plt
.
imshow
(
img
,
cmap
=
'
gray
'
)
plt
.
title
(
'
Original Image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
Original Image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
subplot
(
122
),
plt
.
imshow
(
magnitude_sprectrum
,
cmap
=
'
gray
'
)
plt
.
subplot
(
122
),
plt
.
imshow
(
magnitude_sprectrum
,
cmap
=
'
gray
'
)
plt
.
title
(
'
Magnitude Spectrum
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
Magnitude Spectrum
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
show
plt
.
show
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
#Filtro pasa alto HPF en el dominio de las frencuencias para demarcar contornos:
#Filtro pasa alto HPF en el dominio de las frencuencias para demarcar contornos:
rows
,
cols
=
img
.
shape
rows
,
cols
=
img
.
shape
crow
,
ccol
=
int
(
rows
/
2
),
int
(
cols
/
2
)
crow
,
ccol
=
int
(
rows
/
2
),
int
(
cols
/
2
)
#remover las frecuencias bajas usando una plantilla circular
#remover las frecuencias bajas usando una plantilla circular
mask
=
np
.
ones
((
rows
,
cols
,
2
),
np
.
uint8
)
mask
=
np
.
ones
((
rows
,
cols
,
2
),
np
.
uint8
)
r
=
40
r
=
40
center
=
[
crow
,
ccol
]
center
=
[
crow
,
ccol
]
x
,
y
=
np
.
ogrid
[:
rows
,
:
cols
]
x
,
y
=
np
.
ogrid
[:
rows
,
:
cols
]
mask_area
=
(
x
-
center
[
0
])
**
2
+
(
y
-
center
[
1
])
**
2
<=
r
*
r
mask_area
=
(
x
-
center
[
0
])
**
2
+
(
y
-
center
[
1
])
**
2
<=
r
*
r
mask
[
mask_area
]
=
1
mask
[
mask_area
]
=
1
fshift
=
dft_shift
*
mask
fshift
=
dft_shift
*
mask
fshift_mask_mag
=
2000
*
np
.
log
(
cv2
.
magnitude
(
fshift
[:,:,
0
],
fshift
[:,:,
1
]))
fshift_mask_mag
=
2000
*
np
.
log
(
cv2
.
magnitude
(
fshift
[:,:,
0
],
fshift
[:,:,
1
]))
f_ishift
=
np
.
fft
.
ifftshift
(
fshift
)
f_ishift
=
np
.
fft
.
ifftshift
(
fshift
)
img_back
=
cv2
.
idft
(
f_ishift
)
img_back
=
cv2
.
idft
(
f_ishift
)
img_back
=
cv2
.
magnitude
(
img_back
[:,:,
0
],
img_back
[:,:,
1
])
img_back
=
cv2
.
magnitude
(
img_back
[:,:,
0
],
img_back
[:,:,
1
])
#fshift[crow-30:crow+30,ccol-30:ccol+30]=0
#fshift[crow-30:crow+30,ccol-30:ccol+30]=0
f_ishift
=
np
.
fft
.
ifftshift
(
fshift
)
f_ishift
=
np
.
fft
.
ifftshift
(
fshift
)
img_back
=
np
.
fft
.
ifft2
(
f_ishift
)
img_back
=
np
.
fft
.
ifft2
(
f_ishift
)
img_back
=
np
.
abs
(
img_back
)
img_back
=
np
.
abs
(
img_back
)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
#Filtro pasa Banda BPF aplicando dos circulos concentricos
#Filtro pasa Banda BPF aplicando dos circulos concentricos
rows
,
cols
=
img
.
shape
rows
,
cols
=
img
.
shape
crow
,
ccol
=
int
(
rows
/
2
),
int
(
cols
/
2
)
# circulo centro
crow
,
ccol
=
int
(
rows
/
2
),
int
(
cols
/
2
)
# circulo centro
#remover las frecuencias bajas usando una plantilla circular
#remover las frecuencias bajas usando una plantilla circular
rows
,
cols
=
img
.
shape
rows
,
cols
=
img
.
shape
crow
,
ccol
=
int
(
rows
/
2
),
int
(
cols
/
2
)
crow
,
ccol
=
int
(
rows
/
2
),
int
(
cols
/
2
)
mask
=
np
.
zeros
((
rows
,
cols
,
2
),
np
.
uint8
)
mask
=
np
.
zeros
((
rows
,
cols
,
2
),
np
.
uint8
)
r_out
=
40
r_out
=
40
r_in
=
4
r_in
=
4
center
=
[
crow
,
ccol
]
center
=
[
crow
,
ccol
]
x
,
y
=
np
.
ogrid
[:
rows
,
:
cols
]
x
,
y
=
np
.
ogrid
[:
rows
,
:
cols
]
mask_area
=
np
.
logical_and
(((
x
-
center
[
0
])
**
2
+
(
y
-
center
[
1
])
**
2
>=
r_in
**
2
),
mask_area
=
np
.
logical_and
(((
x
-
center
[
0
])
**
2
+
(
y
-
center
[
1
])
**
2
>=
r_in
**
2
),
((
x
-
center
[
0
])
**
2
+
(
y
-
center
[
1
])
**
2
<=
r_out
**
2
))
((
x
-
center
[
0
])
**
2
+
(
y
-
center
[
1
])
**
2
<=
r_out
**
2
))
mask
[
mask_area
]
=
1
mask
[
mask_area
]
=
1
fshift
=
dft_shift
*
mask
fshift
=
dft_shift
*
mask
fshift_mask_mag
=
2000
*
np
.
log
(
cv2
.
magnitude
(
fshift
[:,
:,
0
],
fshift
[:,
:,
1
]))
fshift_mask_mag
=
2000
*
np
.
log
(
cv2
.
magnitude
(
fshift
[:,
:,
0
],
fshift
[:,
:,
1
]))
f_ishift
=
np
.
fft
.
ifftshift
(
fshift
)
f_ishift
=
np
.
fft
.
ifftshift
(
fshift
)
img_back
=
cv2
.
idft
(
f_ishift
)
img_back
=
cv2
.
idft
(
f_ishift
)
img_back
=
cv2
.
magnitude
(
img_back
[:,:,
0
],
img_back
[:,:,
1
])
img_back
=
cv2
.
magnitude
(
img_back
[:,:,
0
],
img_back
[:,:,
1
])
#fshift[crow-30:crow+30,ccol-30:ccol+30]=0
#fshift[crow-30:crow+30,ccol-30:ccol+30]=0
fig
=
plt
.
figure
(
figsize
=
(
20
,
20
))
fig
=
plt
.
figure
(
figsize
=
(
20
,
20
))
fig
.
add_subplot
(
2
,
2
,
1
),
plt
.
imshow
(
img
,
cmap
=
'
gray
'
)
fig
.
add_subplot
(
2
,
2
,
1
),
plt
.
imshow
(
img
,
cmap
=
'
gray
'
)
plt
.
title
(
'
Input Image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
Input Image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
fig
.
add_subplot
(
2
,
2
,
2
),
plt
.
imshow
(
magnitude_sprectrum
,
cmap
=
'
gray
'
)
fig
.
add_subplot
(
2
,
2
,
2
),
plt
.
imshow
(
magnitude_sprectrum
,
cmap
=
'
gray
'
)
plt
.
title
(
'
After FFT
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
After FFT
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
fig
.
add_subplot
(
2
,
2
,
3
),
plt
.
imshow
(
fshift_mask_mag
,
cmap
=
'
gray
'
)
fig
.
add_subplot
(
2
,
2
,
3
),
plt
.
imshow
(
fshift_mask_mag
,
cmap
=
'
gray
'
)
plt
.
title
(
'
FFT + Mask
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
FFT + Mask
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
fig
.
add_subplot
(
2
,
2
,
4
),
plt
.
imshow
(
img_back
,
cmap
=
'
gray
'
)
fig
.
add_subplot
(
2
,
2
,
4
),
plt
.
imshow
(
img_back
,
cmap
=
'
gray
'
)
plt
.
title
(
'
After FFT Inverse
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
After FFT Inverse
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
#Filtro pasa Banda BPF aplicando dos circulos concentricos
#Filtro pasa Banda BPF aplicando dos circulos concentricos
rows
,
cols
=
img
.
shape
rows
,
cols
=
img
.
shape
crow
,
ccol
=
int
(
rows
/
2
),
int
(
cols
/
2
)
# circulo centro
crow
,
ccol
=
int
(
rows
/
2
),
int
(
cols
/
2
)
# circulo centro
#remover las frecuencias bajas usando una plantilla circular
#remover las frecuencias bajas usando una plantilla circular
rows
,
cols
=
img
.
shape
rows
,
cols
=
img
.
shape
crow
,
ccol
=
int
(
rows
/
2
),
int
(
cols
/
2
)
crow
,
ccol
=
int
(
rows
/
2
),
int
(
cols
/
2
)
mask
=
np
.
zeros
((
rows
,
cols
,
2
),
np
.
uint8
)
mask
=
np
.
zeros
((
rows
,
cols
,
2
),
np
.
uint8
)
#con diferentes radios tal que sean mayor que la zona central, tapando la mayor cantidad de bajas frencuencias.
#con diferentes radios tal que sean mayor que la zona central, tapando la mayor cantidad de bajas frencuencias.
r_out
=
80
r_out
=
80
r_in
=
4
r_in
=
4
center
=
[
crow
,
ccol
]
center
=
[
crow
,
ccol
]
x
,
y
=
np
.
ogrid
[:
rows
,
:
cols
]
x
,
y
=
np
.
ogrid
[:
rows
,
:
cols
]
mask_area
=
np
.
logical_and
(((
x
-
center
[
0
])
**
2
+
(
y
-
center
[
1
])
**
2
>=
r_in
**
2
),
mask_area
=
np
.
logical_and
(((
x
-
center
[
0
])
**
2
+
(
y
-
center
[
1
])
**
2
>=
r_in
**
2
),
((
x
-
center
[
0
])
**
2
+
(
y
-
center
[
1
])
**
2
<=
r_out
**
2
))
((
x
-
center
[
0
])
**
2
+
(
y
-
center
[
1
])
**
2
<=
r_out
**
2
))
mask
[
mask_area
]
=
1
mask
[
mask_area
]
=
1
fshift
=
dft_shift
*
mask
fshift
=
dft_shift
*
mask
fshift_mask_mag
=
2000
*
np
.
log
(
cv2
.
magnitude
(
fshift
[:,
:,
0
],
fshift
[:,
:,
1
]))
fshift_mask_mag
=
2000
*
np
.
log
(
cv2
.
magnitude
(
fshift
[:,
:,
0
],
fshift
[:,
:,
1
]))
f_ishift
=
np
.
fft
.
ifftshift
(
fshift
)
f_ishift
=
np
.
fft
.
ifftshift
(
fshift
)
img_back
=
cv2
.
idft
(
f_ishift
)
img_back
=
cv2
.
idft
(
f_ishift
)
img_back
=
cv2
.
magnitude
(
img_back
[:,:,
0
],
img_back
[:,:,
1
])
img_back
=
cv2
.
magnitude
(
img_back
[:,:,
0
],
img_back
[:,:,
1
])
fig
=
plt
.
figure
(
figsize
=
(
20
,
20
))
fig
=
plt
.
figure
(
figsize
=
(
20
,
20
))
fig
.
add_subplot
(
121
),
plt
.
imshow
(
img
,
cmap
=
'
gray
'
)
fig
.
add_subplot
(
121
),
plt
.
imshow
(
img
,
cmap
=
'
gray
'
)
plt
.
title
(
'
Original Image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
Original Image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
fig
.
add_subplot
(
122
),
plt
.
imshow
(
img_back
,
cmap
=
'
gray
'
)
fig
.
add_subplot
(
122
),
plt
.
imshow
(
img_back
,
cmap
=
'
gray
'
)
plt
.
title
(
'
AFTER FFT Inverse image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
AFTER FFT Inverse image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
plt
.
subplot
(
131
),
plt
.
imshow
(
img
,
cmap
=
'
gray
'
)
plt
.
subplot
(
131
),
plt
.
imshow
(
img
,
cmap
=
'
gray
'
)
plt
.
title
(
'
Input Image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
Input Image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
subplot
(
132
),
plt
.
imshow
(
img_back
,
cmap
=
'
gray
'
)
plt
.
subplot
(
132
),
plt
.
imshow
(
img_back
,
cmap
=
'
gray
'
)
plt
.
title
(
'
Imagen con HPF
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
Imagen con HPF
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
subplot
(
133
),
plt
.
imshow
(
img_back
)
plt
.
subplot
(
133
),
plt
.
imshow
(
img_back
)
plt
.
title
(
'
Imagen Final
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
Imagen Final
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
show
plt
.
show
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
fig
=
plt
.
figure
(
figsize
=
(
20
,
20
))
fig
=
plt
.
figure
(
figsize
=
(
20
,
20
))
fig
.
add_subplot
(
121
),
plt
.
imshow
(
img
,
cmap
=
'
gray
'
)
fig
.
add_subplot
(
121
),
plt
.
imshow
(
img
,
cmap
=
'
gray
'
)
plt
.
title
(
'
Original Image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
Original Image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
fig
.
add_subplot
(
122
),
plt
.
imshow
(
img_back
,
cmap
=
'
gray
'
)
fig
.
add_subplot
(
122
),
plt
.
imshow
(
img_back
,
cmap
=
'
gray
'
)
plt
.
title
(
'
HPF image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
HPF image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
show
plt
.
show
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
#Comparativa para la foto de las rocas
#Comparativa para la foto de las rocas
#recortado de foto
#recortado de foto
#Recortar una imagen
#Recortar una imagen
crop
=
img
[
200
:
400
,
200
:
500
]
crop
=
img
[
200
:
400
,
200
:
500
]
cv2
.
imshow
(
'
Seccion Imagen
'
,
crop
)
cv2
.
imshow
(
'
Seccion Imagen
'
,
crop
)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
#filtro Pasa bajos: LPF
#filtro Pasa bajos: LPF
dft_shift
=
np
.
fft
.
fftshift
(
dft
)
dft_shift
=
np
.
fft
.
fftshift
(
dft
)
rows
,
cols
=
img
.
shape
rows
,
cols
=
img
.
shape
crow
,
ccol
=
int
(
rows
/
2
),
int
(
cols
/
2
)
crow
,
ccol
=
int
(
rows
/
2
),
int
(
cols
/
2
)
mask
=
np
.
zeros
((
rows
,
cols
,
2
),
np
.
uint8
)
mask
=
np
.
zeros
((
rows
,
cols
,
2
),
np
.
uint8
)
mask
[
crow
-
30
:
crow
+
30
,
ccol
-
30
:
ccol
+
30
]
=
1
mask
[
crow
-
30
:
crow
+
30
,
ccol
-
30
:
ccol
+
30
]
=
1
fshift
=
dft_shift
*
mask
fshift
=
dft_shift
*
mask
f_ishift
=
np
.
fft
.
ifftshift
(
fshift
)
f_ishift
=
np
.
fft
.
ifftshift
(
fshift
)
img_back
=
cv2
.
idft
(
f_ishift
)
img_back
=
cv2
.
idft
(
f_ishift
)
img_back
=
cv2
.
magnitude
(
img_back
[:,:,
0
],
img_back
[:,:,
1
])
img_back
=
cv2
.
magnitude
(
img_back
[:,:,
0
],
img_back
[:,:,
1
])
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
fig
=
plt
.
figure
(
figsize
=
(
20
,
20
))
fig
=
plt
.
figure
(
figsize
=
(
20
,
20
))
fig
.
add_subplot
(
121
),
plt
.
imshow
(
img
,
cmap
=
'
gray
'
)
fig
.
add_subplot
(
121
),
plt
.
imshow
(
img
,
cmap
=
'
gray
'
)
plt
.
title
(
'
Original Image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
Original Image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
fig
.
add_subplot
(
122
),
plt
.
imshow
(
img_back
,
cmap
=
'
gray
'
)
fig
.
add_subplot
(
122
),
plt
.
imshow
(
img_back
,
cmap
=
'
gray
'
)
plt
.
title
(
'
LPF image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
title
(
'
LPF image
'
),
plt
.
xticks
([]),
plt
.
yticks
([])
plt
.
show
plt
.
show
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
```
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment