Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 5a0121cc authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Extended GlImageResampler to allow for arbitrary target image dimensions.

parent 699e8ff7
......@@ -44,11 +44,13 @@ namespace campvis {
, p_inputImage("InputImage", "Input Image", "", DataNameProperty::READ)
, p_outputImage("OutputImage", "Output Image", "GlImageResampler.out", DataNameProperty::WRITE)
, p_resampleScale("ResampleScale", "Resampling Scale", .5f, .01f, 10.f)
, p_targetSize("TargetSize", "Size of Resampled Image", cgt::ivec3(128), cgt::ivec3(1), cgt::ivec3(1024))
, _shader(0)
{
addProperty(p_inputImage);
addProperty(p_inputImage, INVALID_RESULT | INVALID_PROPERTIES);
addProperty(p_outputImage);
addProperty(p_resampleScale);
addProperty(p_resampleScale, INVALID_RESULT | INVALID_PROPERTIES);
addProperty(p_targetSize);
}
GlImageResampler::~GlImageResampler() {
......@@ -73,7 +75,8 @@ namespace campvis {
if (img != 0) {
cgt::vec3 originalSize(img->getSize());
cgt::ivec3 resampledSize(cgt::ceil(originalSize * p_resampleScale.getValue()));
//cgt::ivec3 resampledSize(cgt::ceil(originalSize * p_resampleScale.getValue()));
const cgt::ivec3& resampledSize = p_targetSize.getValue();
cgt::TextureUnit inputUnit;
inputUnit.activate();
......@@ -115,4 +118,14 @@ namespace campvis {
}
}
void GlImageResampler::updateProperties(DataContainer& dataContainer) {
ImageRepresentationGL::ScopedRepresentation img(dataContainer, p_inputImage.getValue());
if (img != 0) {
p_targetSize.setMaxValue(cgt::ivec3(img->getSize()) * int(p_resampleScale.getMaxValue()));
p_targetSize.setValue(cgt::ivec3(cgt::vec3(img->getSize()) * p_resampleScale.getValue()));
}
}
}
......@@ -72,11 +72,13 @@ namespace campvis {
DataNameProperty p_outputImage; ///< ID for output gradient volume
FloatProperty p_resampleScale; ///< Resampling Scale
IVec3Property p_targetSize; ///< Size of resampled image
protected:
/// \see AbstractProcessor::updateResult
virtual void updateResult(DataContainer& dataContainer);
virtual void updateProperties(DataContainer& dataContainer);
cgt::Shader* _shader; ///< Shader for resampling
static const std::string loggerCat_;
......@@ -85,3 +87,4 @@ namespace campvis {
}
#endif // GLIMAGERESAMPLER_H__
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment