In addition to the Bayer conversion, other conversion functions are available in IDS peak IPL that can be applied to the camera’s images. These are performed using objects similar to peak::ipl::ImageConverter (see Converting images). Additionally, you can retrieve information about the image (pixel values of a row/column, histogram, value at an image position) and load or save images.
Name
|
Function
|
peak::ipl::ColorCorrector
|
Performs color correction, see Applying color correction.
|
peak::ipl::GammaCorrector
|
Performs gamma correction.
|
peak::ipl::ImageTransformer
|
Performs flips and rotations.
|
peak::ipl::ImageReader
|
Creates an image (peak::ipl::Image) from an image file.
|
peak::ipl::ImageWriter
|
Saves an image (peak::ipl::Image) into an image file, see Saving/loading images.
|
peak::ipl::PixelColumn
|
Creates a vertical intensity profile for a special column of an image, see Image data and histogram.
|
peak::ipl::PixelRow
|
Creates a horizontal intensity profile for a specific line of an image, see Image data and histogram.
|
peak::ipl::Histogram
|
Returns a histogram of the image, see Image data and histogram.
|
Flipping an image
After converting the Bayer image in the image acquisition loop, the flipping is performed via a peak::ipl::ImageTransformer object. This object should be created previously in a central part of the program.
genericC++
|
peak::ipl::ImageTransformer m_imageTransformerIPL;
|
Flipping in X direction with creation of a new peak::ipl::Image
genericC++
|
auto imageTransformed = m_imageTransformerIPL.MirrorLeftRight(image);
|
Flipping in X direction into an existing peak::ipl::Image
genericC++
|
m_imageTransformerIPL.MirrorLeftRightInPlace(image);
|
Flipping in Y direction with creation of a new peak::ipl::Image
genericC++
|
auto imageTransformed = m_imageTransformerIPL.MirrorUpDown(image)
|
Flipping in Y direction into an existing peak::ipl::Image
genericC++
|
m_imageTransformerIPL.MirrorUpDownInPlace(image);
|
Flipping in both directions with creation of a new peak::ipl::Image
genericC++
|
auto imageTransformed = m_imageTransformerIPL.MirrorUpDownLeftRight(image);
|
Flipping in both directions into an existing peak::ipl::Image
genericC++
|
m_imageTransformerIPL.MirrorUpDownLeftRightInPlace(image);
|
Rotation of the image by 180 degrees
genericC++
|
// Rotate and create new image
auto imageRotate = m_imageTransformerIPL.Rotate(image, peak::ipl::ImageTransformer::RotationAngle::Degree180);
// Rotate in place
m_imageTransformerIPL.RotateInPlace(image, peak::ipl::ImageTransformer::RotationAngle::Degree180);
|
Rotation of the image by 90 degrees clockwise
genericC++
|
// Rotate and create new image
auto imageRotate = m_imageTransformerIPL.Rotate(image, peak::ipl::ImageTransformer::RotationAngle::Degree90Clockwise);
// Rotate in place
m_imageTransformerIPL.RotateInPlace(image, peak::ipl::ImageTransformer::RotationAngle::Degree90Clockwise);
|
Rotation of the image by 90 degrees counterclockwise
genericC++
|
// Rotate and create new image
auto imageRotate = m_imageTransformerIPL.Rotate(image, peak::ipl::ImageTransformer::RotationAngle::Degree90Counterclockwise);
// Rotate in place
m_imageTransformerIPL.RotateInPlace(image, peak::ipl::ImageTransformer::RotationAngle::Degree90Counterclockwise);
|
Complete example: image acquisition loop with flipping and rotation
By using the "InPlace" functions, the result image is automatically written into the existing image.
peak::ipl::ImageTransformer m_imageTransformerIPL;
while (m_running)
{
try
{
// Get buffer from device's DataStream. Wait 5000 ms. The buffer is automatically locked until it is queued again.
const auto buffer = m_dataStream->WaitForFinishedBuffer(5000);
// Create IDS peak IPL image from buffer
const auto image = peak::BufferTo<Image>(buffer);
// Convert it to RGBa8 format by debayering
auto imageProcessed = image.ConvertTo(peak::ipl::PixelFormatName::BGRa8, peak::ipl::ConversionMode::Fast);
// Queue buffer again
m_dataStream->QueueBuffer(buffer);
// Mirror x and y
m_imageTransformerIPL.MirrorUpDownLeftRightInPlace(imageProcessed);
// Rotate by 180 degrees
m_imageTransformerIPL.RotateInPlace(imageProcessed, peak::ipl::ImageTransformer::RotationAngle::Degree180);
}
catch (const std::exception& e)
{
// ...
}
}
|
var m_imageTransformerIPL = new peak.ipl.ImageTransformer();
while (m_running)
{
try
{
// Get buffer from device's DataStream. Wait 5000 ms. The buffer is automatically locked until it is queued again.
var buffer = m_dataStream.WaitForFinishedBuffer(5000);
// Create IDS peak IPL image from buffer
var image = new peak.ipl.Image((peak.ipl.PixelFormatName)buffer.PixelFormat(), buffer.BasePtr(),
buffer.Size(), buffer.Width(), buffer.Height());
// Convert it to RGBa8 format by debayering
var imageProcessed = image.ConvertTo(peak.ipl.PixelFormatName.BGRa8, peak.ipl.ConversionMode.Fast);
// Queue buffer again
m_dataStream.QueueBuffer(buffer);
// Mirror x and y
m_imageTransformerIPL.MirrorUpDownLeftRightInPlace(imageProcessed);
// Rotate by 180 degrees
m_imageTransformerIPL.RotateInPlace(imageProcessed, peak.ipl.ImageTransformer.RotationAngle.Degree180);
}
catch (Exception e)
{
// ...
}
}
|
from ids_peak import ids_peak_ipl_extension
m_image_transformer_ipl = ids_peak_ipl.ImageTransformer()
while m_running:
try:
# Get buffer from device's DataStream. Wait 5000 ms. The buffer is automatically locked until it is queued again.
buffer = m_data_stream.WaitForFinishedBuffer(5000)
# Create IDS peak IPL image from buffer
image = ids_peak_ipl_extension.BufferToImage(buffer)
# Convert it to RGBa8 format by debayering
image_processed = image.ConvertTo(ids_peak_ipl.PixelFormatName_BGRa8, ids_peak_ipl.ConversionMode_Fast)
# Queue buffer again
m_data_stream.QueueBuffer(buffer)
# Mirror x and y
m_image_transformer_ipl.MirrorUpDownLeftRightInPlace(image_processed)
# Rotate by 180 degrees
m_image_transformer_ipl.RotateInPlace(image_processed, ids_peak_ipl.ImageTransformer.RotationAngle_Degree180)
except Exception as e:
# ...
str_error = str(e)
|