blob: f77ce1e89dadf18e06ad24c377f62d108702bcb6 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001/*
2 * Copyright (c) 2021 Arm Limited. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17#include "ImageUtils.hpp"
18
19void convertImgIoInt8(void * data, const size_t sz)
20{
21 uint8_t * tmp_req_data = (uint8_t *)data;
22 int8_t * tmp_signed_req_data = (int8_t *) data;
23
24 for (size_t i = 0; i < sz; ++i) {
25 tmp_signed_req_data[i] = (int8_t)(
26 (int32_t)(tmp_req_data[i]) - 128);
27 }
28}
29
30void convertImgIoGreyscale(const uint8_t * srcPtr, uint8_t * dstPtr, const size_t sz)
31{
32 for (size_t i = 0; i < sz; ++i, srcPtr += 3) {
33 *dstPtr++ = 0.2989 * (*srcPtr) +
34 0.587 * (*(srcPtr+1)) +
35 0.114 * (*(srcPtr+2));
36 }
37}