Comments (1)
Hi,
I kept studying that error and after some 'debugging' in the raw2temp module, I discovered that my thermal_np_array had some 0 values. I'm assuming that these are some hardware bad detections and I'm replacing those 0s with some non zero value from the same row (e.g, the first non zero value). I'm including this piece of code
for row in thermal_np:
if 0 in row:
non_zeros = row[row != 0]
row[row == 0] = non_zeros[0]
Update 18-06-21. That method led to bad coloured images. I ended up adding the following module.
def zeros_filter(matrix, row, col):
"""
Input: bidimensional np.array, row and column where the 0 lies.
Output: average of the surrounding values.
"""
shape = np.shape(matrix)
rows = shape[0]
cols = shape[1]
# Surroundings depends on the position of the element (corners, edges or inner
# points). Each 'if/elif' is for each possible position in the matrix. Surrounding
# non-zero elements are selected for the interpolation and if there isn't any, a
# non-zero value from the row is taken.
if (row not in {0,rows-1}) and (col not in {0,cols-1}): # inner points
surr = np.array([matrix[row-1][col-1],matrix[row-1][col],matrix[row][col+1],
matrix[row][col-1],matrix[row][col+1],
matrix[row+1][col-1],matrix[row+1][col],matrix[row+1][col+1]])
surr = surr[surr != 0]
if len(surr) == 0:
new_value = matrix[row][matrix[row] != 0][0]
else:
mean = np.mean(surr)
new_value = mean
elif (row == 0): # top row
if (col == 0):
surr = np.array([matrix[row][col+1],matrix[row+1][col],
matrix[row+1][col+1]])
surr = surr[surr != 0]
if len(surr) == 0:
new_value = matrix[row][matrix[row] != 0][0]
else:
mean = np.mean(surr)
new_value = mean
elif (col == cols-1):
surr = np.array([matrix[row][col-1],matrix[row+1][col],
matrix[row+1][col-1]])
surr = surr[surr != 0]
if len(surr) == 0:
new_value = matrix[row][matrix[row] != 0][0]
else:
mean = np.mean(surr)
new_value = mean
else:
surr = np.array([matrix[row][col-1],matrix[row][col+1],
matrix[row+1][col-1],matrix[row+1][col],matrix[row+1][col+1]])
surr = surr[surr != 0]
if len(surr) == 0:
new_value = matrix[row][matrix[row] != 0][0]
else:
mean = np.mean(surr)
new_value = mean
elif (row == rows-1): # bottom row
if (col == 0):
surr = np.array([matrix[row][col+1],matrix[row-1][col],
matrix[row][col+1]])
surr = surr[surr != 0]
if len(surr) == 0:
new_value = matrix[row][matrix[row] != 0][0]
else:
mean = np.mean(surr)
new_value = mean
elif (col == cols-1):
surr = np.array([matrix[row][col-1],matrix[row-1][col],
matrix[row-1][col-1]])
surr = surr[surr != 0]
if len(surr) == 0:
new_value = matrix[row][matrix[row] != 0][0]
else:
mean = np.mean(surr)
new_value = mean
else:
surr = np.array([matrix[row-1][col-1],matrix[row-1][col],matrix[row][col+1],
matrix[row][col-1],matrix[row][col+1]])
surr = surr[surr != 0]
if len(surr) == 0:
new_value = matrix[row][matrix[row] != 0][0]
else:
mean = np.mean(surr)
new_value = mean
elif (col == 0): # first column
surr = np.array([matrix[row-1][col],matrix[row][col+1],
matrix[row][col+1],
matrix[row+1][col],matrix[row+1][col+1]])
surr = surr[surr != 0]
if len(surr) == 0:
new_value = matrix[row][matrix[row] != 0][0]
else:
mean = np.mean(surr)
new_value = mean
elif (col == cols-1): # last column
surr = np.array([matrix[row-1][col],matrix[row][col-1],
matrix[row][col-1],
matrix[row+1][col],matrix[row+1][col-1]])
surr = surr[surr != 0]
if len(surr) == 0:
new_value = matrix[row][matrix[row] != 0][0]
else:
mean = np.mean(surr)
new_value = mean
return new_value
I think variable names and comments are clear enough. It is some kind of "convolution". If someone knows how to do it in a easier way I'd appreciate it :)
from read_thermal.py.
Related Issues (12)
- Hello! I encountered an error when running the project. What can I do? Tks pro
- extract temperature info from flir video HOT 2
- No-Visual Output HOT 1
- after specified correct path got the Value Error
- I can't extract the Thermal Image from JPG HOT 1
- array size HOT 1
- What is the license for this project? HOT 3
- Working with multiple images and ironbow filter
- Extracting exif header information
- Is there any coordinate relationship between thermal and visible image?
- Support for Flir Lepton HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from read_thermal.py.