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

Function GetImageDataAsNormalizedFloats

tests/InferenceTestImage.cpp:333–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

331}
332
333std::vector<float> GetImageDataAsNormalizedFloats(ImageChannelLayout layout,
334 const InferenceTestImage& image)
335{
336 std::vector<float> imageData;
337 const unsigned int h = image.GetHeight();
338 const unsigned int w = image.GetWidth();
339
340 const unsigned int rDstIndex = GetImageChannelIndex(layout, ImageChannel::R);
341 const unsigned int gDstIndex = GetImageChannelIndex(layout, ImageChannel::G);
342 const unsigned int bDstIndex = GetImageChannelIndex(layout, ImageChannel::B);
343
344 imageData.resize(h * w * 3);
345 unsigned int offset = 0;
346
347 for (unsigned int j = 0; j < h; ++j)
348 {
349 for (unsigned int i = 0; i < w; ++i)
350 {
351 uint8_t r, g, b;
352 std::tie(r, g, b) = image.GetPixelAs3Channels(i, j);
353
354 imageData[offset+rDstIndex] = float(r) / 255.0f;
355 imageData[offset+gDstIndex] = float(g) / 255.0f;
356 imageData[offset+bDstIndex] = float(b) / 255.0f;
357 offset += 3;
358 }
359 }
360
361 return imageData;
362}

Callers 1

GetTestCaseDataMethod · 0.85

Calls 5

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

Tested by

no test coverage detected