aboutsummaryrefslogtreecommitdiff
path: root/tests/InferenceTestImage.cpp
diff options
context:
space:
mode:
authorsurmeh01 <surabhi.mehta@arm.com>2018-03-29 16:29:27 +0100
committersurmeh01 <surabhi.mehta@arm.com>2018-03-29 16:29:27 +0100
commitbceff2fb3fc68bb0aa88b886900c34b77340c826 (patch)
treed867d3e090d58d3012dfbbac456e9ea8c7f789bc /tests/InferenceTestImage.cpp
parent4fcda0101ec3d110c1d6d7bee5c83416b645528a (diff)
downloadarmnn-bceff2fb3fc68bb0aa88b886900c34b77340c826.tar.gz
Release 18.03
Diffstat (limited to 'tests/InferenceTestImage.cpp')
-rw-r--r--tests/InferenceTestImage.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/InferenceTestImage.cpp b/tests/InferenceTestImage.cpp
index 8fc6f12867..205460a2f2 100644
--- a/tests/InferenceTestImage.cpp
+++ b/tests/InferenceTestImage.cpp
@@ -222,3 +222,34 @@ std::vector<float> GetImageDataInArmNnLayoutAsFloatsSubtractingMean(ImageChannel
return value - mean[channelIndex];
});
}
+
+std::vector<float> GetImageDataAsNormalizedFloats(ImageChannelLayout layout,
+ const InferenceTestImage& image)
+{
+ std::vector<float> imageData;
+ const unsigned int h = image.GetHeight();
+ const unsigned int w = image.GetWidth();
+
+ const unsigned int rDstIndex = GetImageChannelIndex(layout, ImageChannel::R);
+ const unsigned int gDstIndex = GetImageChannelIndex(layout, ImageChannel::G);
+ const unsigned int bDstIndex = GetImageChannelIndex(layout, ImageChannel::B);
+
+ imageData.resize(h * w * 3);
+ unsigned int offset = 0;
+
+ for (unsigned int j = 0; j < h; ++j)
+ {
+ for (unsigned int i = 0; i < w; ++i)
+ {
+ uint8_t r, g, b;
+ std::tie(r, g, b) = image.GetPixelAs3Channels(i, j);
+
+ imageData[offset+rDstIndex] = float(r) / 255.0f;
+ imageData[offset+gDstIndex] = float(g) / 255.0f;
+ imageData[offset+bDstIndex] = float(b) / 255.0f;
+ offset += 3;
+ }
+ }
+
+ return imageData;
+} \ No newline at end of file