MCPcopy Create free account
hub / github.com/ARM-software/armnn / GetImageDataInArmNnLayoutAsFloats

Function GetImageDataInArmNnLayoutAsFloats

tests/InferenceTestImage.cpp:279–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277
278template <typename TProcessValueCallable>
279std::vector<float> GetImageDataInArmNnLayoutAsFloats(ImageChannelLayout channelLayout,
280 const InferenceTestImage& image,
281 TProcessValueCallable processValue)
282{
283 const unsigned int h = image.GetHeight();
284 const unsigned int w = image.GetWidth();
285
286 std::vector<float> imageData;
287 imageData.resize(h * w * 3);
288
289 for (unsigned int j = 0; j < h; ++j)
290 {
291 for (unsigned int i = 0; i < w; ++i)
292 {
293 uint8_t r, g, b;
294 std::tie(r, g, b) = image.GetPixelAs3Channels(i, j);
295
296 // ArmNN order: C, H, W
297 const unsigned int rDstIndex = GetImageChannelIndex(channelLayout, ImageChannel::R) * h * w + j * w + i;
298 const unsigned int gDstIndex = GetImageChannelIndex(channelLayout, ImageChannel::G) * h * w + j * w + i;
299 const unsigned int bDstIndex = GetImageChannelIndex(channelLayout, ImageChannel::B) * h * w + j * w + i;
300
301 imageData[rDstIndex] = processValue(ImageChannel::R, float(r));
302 imageData[gDstIndex] = processValue(ImageChannel::G, float(g));
303 imageData[bDstIndex] = processValue(ImageChannel::B, float(b));
304 }
305 }
306
307 return imageData;
308}
309
310std::vector<float> GetImageDataInArmNnLayoutAsNormalizedFloats(ImageChannelLayout layout,
311 const InferenceTestImage& image)

Calls 5

GetImageChannelIndexFunction · 0.85
resizeMethod · 0.80
GetPixelAs3ChannelsMethod · 0.80
GetHeightMethod · 0.45
GetWidthMethod · 0.45

Tested by

no test coverage detected