SourceXtractorPlusPlus
0.15
Please provide a description of the project.
|
#include <ImageAccessor.h>
Public Types | |
enum | AccessHint { TOP_LEFT , CENTERED , BOTTOM_RIGHT } |
![]() | |
using | PixelType = T |
Public Member Functions | |
~ImageAccessor ()=default | |
ImageAccessor (std::shared_ptr< const Image< T >> img, AccessHint hint=TOP_LEFT, int w=64, int h=1) | |
ImageAccessor (const Image< T > &img, AccessHint hint=TOP_LEFT, int w=64, int h=64) | |
ImageAccessor (const ImageAccessor< T > &)=delete | |
ImageAccessor (ImageAccessor< T > &&)=default | |
ImageAccessor< T > & | operator= (const ImageAccessor< T > &)=delete |
T | getValue (int x, int y) |
T | getValue (const PixelCoordinate &coord) |
std::string | getRepr () const override |
Get a string identifying this image in a human readable manner. More... | |
int | getWidth () const override |
Returns the width of the image in pixels. More... | |
int | getHeight () const override |
Returns the height of the image in pixels. More... | |
std::shared_ptr< ImageChunk< T > > | getChunk (int x, int y, int width, int height) const override |
![]() | |
virtual | ~Image ()=default |
Destructor. More... | |
std::shared_ptr< ImageChunk< T > > | getChunk (const PixelCoordinate &start, const PixelCoordinate &end) const |
bool | isInside (int x, int y) const |
Returns true if the given coordinates are inside the image bounds. More... | |
Private Member Functions | |
void | selectChunk (const PixelCoordinate &coord) |
void | nextCoordinates (const PixelCoordinate &coord) |
PixelCoordinate | firstCoordinates (const PixelCoordinate &coord) |
Private Attributes | |
const Image< T > * | m_image |
std::shared_ptr< const Image< T > > | m_keep_alive |
std::shared_ptr< const ImageChunk< T > > | m_chunk |
PixelCoordinate | m_chunk_min |
PixelCoordinate | m_chunk_max |
AccessHint | m_hint |
int | m_read_width |
int | m_read_height |
The Image interface used to have a getValue(x, y) method, but this was suboptimal when using image types that need to keep state and be thread safe (i.e. BufferedImage) It was dropped, and this accessor is intended to provide an easy alternative. Unlike the images, the accessor is explicitly not thread safe and not intended to be passed around or copied. To reduce performance penalties, it can be hinted about the chunk size and the access pattern. For instance, if you know the access is away from the first coordinate in a circular fashion, the first chunk will be centered on your first read to reduce requests.
T | Pixel type |
Definition at line 41 of file ImageAccessor.h.
enum SourceXtractor::ImageAccessor::AccessHint |
Hints about the access pattern
Even if you don't honor the hint, it will still work!
Enumerator | |
---|---|
TOP_LEFT | |
CENTERED | |
BOTTOM_RIGHT |
Definition at line 48 of file ImageAccessor.h.
|
default |
Destructor
|
inline |
Constructor
img | Image to be accessed |
hint | Hint about the access pattern |
w | Width of the chunk size |
h | Height of the chunk size |
Definition at line 72 of file ImageAccessor.h.
References std::move().
|
inline |
Definition at line 76 of file ImageAccessor.h.
|
delete |
Can not be copied!
|
default |
But it can be moved
|
inlineprivate |
Definition at line 180 of file ImageAccessor.h.
References SourceXtractor::ImageAccessor< T >::BOTTOM_RIGHT, SourceXtractor::ImageAccessor< T >::CENTERED, SourceXtractor::ImageAccessor< T >::m_hint, SourceXtractor::ImageAccessor< T >::m_read_height, SourceXtractor::ImageAccessor< T >::m_read_width, SourceXtractor::PixelCoordinate::m_x, SourceXtractor::PixelCoordinate::m_y, and SourceXtractor::ImageAccessor< T >::TOP_LEFT.
Referenced by SourceXtractor::ImageAccessor< T >::nextCoordinates().
|
inlineoverridevirtual |
Implements SourceXtractor::Image< T >.
Definition at line 128 of file ImageAccessor.h.
References SourceXtractor::ImageAccessor< T >::m_image, x, and y.
|
inlineoverridevirtual |
Returns the height of the image in pixels.
Implements SourceXtractor::Image< T >.
Definition at line 124 of file ImageAccessor.h.
References SourceXtractor::ImageAccessor< T >::m_image.
Referenced by SourceXtractor::MirrorImage< T >::getChunk(), SourceXtractor::PaddedImage< T, CoordinateInterpolation >::getChunk(), SourceXtractor::PaddedImage< T, nullptr >::getChunk(), and SourceXtractor::RecenterImage< T >::getChunk().
|
inlineoverridevirtual |
Get a string identifying this image in a human readable manner.
Implements SourceXtractor::Image< T >.
Definition at line 116 of file ImageAccessor.h.
References SourceXtractor::ImageAccessor< T >::m_image.
|
inline |
Definition at line 107 of file ImageAccessor.h.
References SourceXtractor::ImageAccessor< T >::m_chunk, SourceXtractor::ImageAccessor< T >::m_chunk_min, and SourceXtractor::ImageAccessor< T >::selectChunk().
|
inline |
Drop-in replacement for Image<T>::getValue
Coordinates are always relative to the full image! As far as the caller is concerned, there is no chunk
Definition at line 100 of file ImageAccessor.h.
References SourceXtractor::ImageAccessor< T >::m_chunk, SourceXtractor::ImageAccessor< T >::m_chunk_min, SourceXtractor::PixelCoordinate::m_x, SourceXtractor::PixelCoordinate::m_y, SourceXtractor::ImageAccessor< T >::selectChunk(), x, and y.
Referenced by TestImage::addBackgroundNoise(), TestImage::addPoissonNoise(), ModelFitting::ImageTraits< WriteableInterfaceTypePtr >::at(), SourceXtractor::FlexibleModelFittingTask::computeChiSquaredForFrame(), SourceXtractor::fillCutout(), SourceXtractor::MirrorImage< T >::getChunk(), SourceXtractor::PaddedImage< T, CoordinateInterpolation >::getChunk(), SourceXtractor::PaddedImage< T, nullptr >::getChunk(), SourceXtractor::RecenterImage< T >::getChunk(), SourceXtractor::SubImage< T >::getChunk(), SourceXtractor::MoffatCheckImage::handleMessage(), TestImage::mainMethod(), ModelFitting::ImageTraits< WriteableInterfaceTypePtr >::WriteableSetter::operator WriteableInterfaceType::PixelType(), ModelFitting::ImageTraits< WriteableInterfaceTypePtr >::WriteableSetter::operator+=(), TestImage::saturate(), SourceXtractor::ScaledImageSource< T >::ScaledImageSource(), ModelFitting::ImageTraits< WriteableInterfaceTypePtr >::shiftResizeLancszos(), SourceXtractor::FlexibleModelFittingTask::updateCheckImages(), and SourceXtractor::FitsWriter::writeFile().
|
inlineoverridevirtual |
Returns the width of the image in pixels.
Implements SourceXtractor::Image< T >.
Definition at line 120 of file ImageAccessor.h.
References SourceXtractor::ImageAccessor< T >::m_image.
Referenced by SourceXtractor::MirrorImage< T >::getChunk(), SourceXtractor::PaddedImage< T, CoordinateInterpolation >::getChunk(), SourceXtractor::PaddedImage< T, nullptr >::getChunk(), and SourceXtractor::RecenterImage< T >::getChunk().
|
inlineprivate |
Try to guess what's coming next. It just uses some rudimentary heuristics.
Definition at line 155 of file ImageAccessor.h.
References SourceXtractor::ImageAccessor< T >::BOTTOM_RIGHT, SourceXtractor::ImageAccessor< T >::CENTERED, SourceXtractor::PixelCoordinate::clip(), SourceXtractor::ImageAccessor< T >::firstCoordinates(), SourceXtractor::ImageAccessor< T >::m_chunk, SourceXtractor::ImageAccessor< T >::m_chunk_max, SourceXtractor::ImageAccessor< T >::m_chunk_min, SourceXtractor::ImageAccessor< T >::m_hint, SourceXtractor::ImageAccessor< T >::m_image, SourceXtractor::ImageAccessor< T >::m_read_height, SourceXtractor::ImageAccessor< T >::m_read_width, SourceXtractor::PixelCoordinate::m_x, SourceXtractor::PixelCoordinate::m_y, and SourceXtractor::ImageAccessor< T >::TOP_LEFT.
Referenced by SourceXtractor::ImageAccessor< T >::selectChunk().
|
delete |
Can not be assigned either
|
inlineprivate |
Verify if the requested coordinates can be satisfied, and asks for the next chunk otherwise
Definition at line 144 of file ImageAccessor.h.
References SourceXtractor::ImageAccessor< T >::m_chunk, SourceXtractor::ImageAccessor< T >::m_chunk_max, SourceXtractor::ImageAccessor< T >::m_chunk_min, SourceXtractor::ImageAccessor< T >::m_image, and SourceXtractor::ImageAccessor< T >::nextCoordinates().
Referenced by SourceXtractor::ImageAccessor< T >::getValue().
|
private |
Definition at line 135 of file ImageAccessor.h.
Referenced by SourceXtractor::ImageAccessor< T >::getValue(), SourceXtractor::ImageAccessor< T >::nextCoordinates(), and SourceXtractor::ImageAccessor< T >::selectChunk().
|
private |
Definition at line 136 of file ImageAccessor.h.
Referenced by SourceXtractor::ImageAccessor< T >::nextCoordinates(), and SourceXtractor::ImageAccessor< T >::selectChunk().
|
private |
Definition at line 136 of file ImageAccessor.h.
Referenced by SourceXtractor::ImageAccessor< T >::getValue(), SourceXtractor::ImageAccessor< T >::nextCoordinates(), and SourceXtractor::ImageAccessor< T >::selectChunk().
|
private |
Definition at line 137 of file ImageAccessor.h.
Referenced by SourceXtractor::ImageAccessor< T >::firstCoordinates(), and SourceXtractor::ImageAccessor< T >::nextCoordinates().
|
private |
Definition at line 133 of file ImageAccessor.h.
Referenced by SourceXtractor::ImageAccessor< T >::getChunk(), SourceXtractor::ImageAccessor< T >::getHeight(), SourceXtractor::ImageAccessor< T >::getRepr(), SourceXtractor::ImageAccessor< T >::getWidth(), SourceXtractor::ImageAccessor< T >::nextCoordinates(), and SourceXtractor::ImageAccessor< T >::selectChunk().
|
private |
Definition at line 134 of file ImageAccessor.h.
|
private |
Definition at line 138 of file ImageAccessor.h.
Referenced by SourceXtractor::ImageAccessor< T >::firstCoordinates(), and SourceXtractor::ImageAccessor< T >::nextCoordinates().
|
private |
Definition at line 138 of file ImageAccessor.h.
Referenced by SourceXtractor::ImageAccessor< T >::firstCoordinates(), and SourceXtractor::ImageAccessor< T >::nextCoordinates().