0

I have data data as images taken from the camera hyperspectral. The file will come out in .hdr and .raw format. When opening the image, you must use the envi.open command. The point is that the data_nparr obtained from the raw image has a background color. which I want the background to be a word color. In what ways can we do this with the images that come from the camera hyperspectral?

Can we adjust the wavelength at all? Because if there is still a background when going to the corrected or scanning process, the image will not be clear.

P.S. I have made a sample image for you to see. I'm sorry that I can't show you a real example.

code :

from spectral import *
from spectral import imshow, view_cube
import spectral.io.envi as envi
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import cv2 as cv2
import numpy as np
import pandas as pd

# load Data
name_file ="data_01"
dark_ref = envi.open('Data/Coated/Coated_1/'+name_file+'/capture/DARKREF_'+name_file+'.hdr',
          'Data/Coated/Coated_1/'+name_file+'/capture/DARKREF_'+name_file+'.raw')
white_ref = envi.open('Data/Coated/Coated_1/'+name_file+'/capture/WHITEREF_'+name_file+'.hdr',
          'Data/Coated/Coated_1/'+name_file+'/capture/WHITEREF_'+name_file+'.raw')
data_ref = envi.open('Data/Coated/Coated_1/'+name_file+'/capture/'+name_file+'.hdr',
          'Data/Coated/Coated_1/'+name_file+'/capture/'+name_file+'.raw')

white_nparr = np.array(white_ref.load())
dark_nparr = np.array(dark_ref.load())
data_nparr = np.array(data_ref.load())

# Average white/dark reference over the first axis 
dark = np.mean(white_nparr, axis=0, keepdims=True)
white = np.mean(dark_nparr, axis=0, keepdims=True)

#scan data
corrected_nparr = np.divide(
    np.subtract(data_nparr, dark),
    np.subtract(white, dark))

enter image description here

rioV8
  • 24,506
  • 3
  • 32
  • 49
  • It isn't clear what you mean by "word color". If you are trying to prevent the background from affecting your image correction, you might try using a numpy [mased array](https://numpy.org/doc/stable/reference/maskedarray.generic.html). – bogatron Sep 03 '22 at 21:06

0 Answers0