IDS Peak comfortSDK, genericSDK, IPL, and AFL developer manuals are external documents. Please contact us if you need them.
The adaptive hot pixel correction can detect and correct hot pixels dynamically while the application is running. The method is "adaptive" because the pixel values are effectively adjusted to match surrounding pixels in terms of direction and intensity.
![hint_info](./images/hint_info.png)
|
Note the following hints for adaptive hot pixel correction:
•The adaptive hot pixel correction is performed on the host.
•The adaptive hot pixel correction can only be used with RAW pixel formats.
•Image pre-processing steps in the camera have an effect on hot pixel correction.
•Subsequent image processing steps on the host, e.g. debayering, color correction, etc., do not have an effect on hot pixel correction.
For example, if you flip the image in the camera (ReverseX/ReverseY) , you must redetect the hot pixel list afterwards.
|
Creating an object for hot pixel correction
genericC++
|
peak::ipl::HotpixelCorrection m_hotpixelCorrection;
|
Querying or setting the sensitivity
The sensitivity can be set in 5 levels (SensitivityLevel1 ... SensitivityLevel5), where 1 is the least sensitive and 5 is the most sensitive to search for hot pixels in the image.
genericC++
|
// Get current sensitivity level
auto currentSensitivity = m_hotpixelCorrection.Sensitivity();
// Set level to "1"
m_hotpixelCorrection.SetSensitivity(peak::ipl::HotpixelCorrection::SensitivityLevel::SensitivityLevel1);
|
Querying or setting the gain factor
The currently set gain must be passed to the hot pixel correction so that this value is taken into account by the correction. The analog master gain is used here.
genericC++
|
// Get current gain factor
auto currentGainFactor = m_hotpixelCorrection.GainFactorPercent();
m_nodemapRemoteDevice->FindNode<peak::core::nodes::EnumerationNode>("GainSelector")->SetCurrentEntry("AnalogAll");
auto gain = m_nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("Gain")->Value();
auto gain_percent = static_cast<uint32_t>(gain * 100);
m_hotpixelCorrection.SetGainFactorPercent(gain_percent);
|
Detecting hot pixels in an image
The "Detect()" function dynamically finds hot pixels in the specified peak::ipl::Image and returns them in a vector. You do not have to perform the detection on every image. It makes sense to proceed as follows:
1.Set the camera parameters for the desired environmental scenario.
2.Determine the hot pixel vector once using a homogeneous surface.
3.Hot pixel correction is applied to each newly received image.
genericC++
|
auto hotpixelVector = m_hotpixelCorrection.Detect(image);
|
Correcting the hot pixels in an image
genericC++
|
// Correct image and return new image
auto imageCorrected = m_hotpixelCorrection.Correct(image, hotpixelVector);
// Alternative: Correct into the same image
image = m_hotpixelCorrection.Correct(image, hotpixelVector);
|
Complete example: image acquisition with hot pixel detection and correction
peak::ipl::HotpixelCorrection m_hotpixelCorrection;
try
{
// Get buffer from device's DataStream
const auto buffer = m_dataStream->WaitForFinishedBuffer(5000);
auto image = peak::BufferTo<peak::ipl::Image>(buffer);
auto vec = m_hotpixelCorrection.Detect(image);
image = m_hotpixelCorrection.Correct(image, vec);
// Create IDS peak IPL image for debayering and convert it to RGBa8 format
image.ConvertTo(peak::ipl::PixelFormatName::BGRa8);
// Queue buffer so that it can be used again
m_dataStream->QueueBuffer(buffer);
}
catch (const std::exception& e)
{
// ...
}
|
var m_hotpixelCorrection = new peak.ipl.HotpixelCorrection();
try
{
// Get buffer from device's DataStream
var buffer = m_dataStream.WaitForFinishedBuffer(5000);
var image = new peak.ipl.Image((peak.ipl.PixelFormatName)buffer.PixelFormat(), buffer.BasePtr(),
buffer.Size(), buffer.Width(), buffer.Height(), buffer.Timestamp_ns());
var vec = m_hotpixelCorrection.Detect(image);
image = m_hotpixelCorrection.Correct(image, vec);
// Create IDS peak IPL image for debayering and convert it to RGBa8 format
image.ConvertTo(peak.ipl.PixelFormatName.BGRa8);
// Queue buffer so that it can be used again
m_dataStream.QueueBuffer(buffer);
}
catch (Exception e)
{
// ...
}
|
m_hotpixel_correction = ids_peak_ipl.HotpixelCorrection()
try:
# Get buffer from device's DataStream
buffer = m_data_stream.WaitForFinishedBuffer(5000)
image = ids_peak_ipl.Image.CreateFromSizeAndBuffer(
buffer.PixelFormat(),
buffer.BasePtr(),
buffer.Size(),
buffer.Width(),
buffer.Height()
)
vec = m_hotpixel_correction.Detect(image)
image = m_hotpixel_correction.Correct(image, vec)
# Create IDS peak IPL image for debayering and convert it to RGBa8 format
image.ConvertTo(ids_peak_ipl.PixelFormatName_BGRa8)
# Queue buffer so that it can be used again
m_data_stream.QueueBuffer(buffer)
except Exception as e:
# ...
str_error = str(e)
|