Questions tagged [uint16]
127 questions
0
votes
3 answers
Fill 2D std::array of uint16_t in C++
I have a matrix in C++ defined as a std::array of std::array that I would like to set uniformly to a given value. I can't find something as simple as C-style memset for C-Style array (int a[10][10] etc...).
I tried something using std::memset but…

Pierre Baret
- 1,773
- 2
- 17
- 35
0
votes
2 answers
How do I add transparency to a uint16 image in python (in the context of using connectedcomponents in opencv)?
With a uint8, 3-channel image and uint8 binary mask, I have done the following in opencv and python in order to change an object on a black background into an object on a transparent background:
# Separate image into its 3 channels
b, g, r =…

sb000
- 11
- 1
- 3
0
votes
0 answers
How to convert UInt16 into wav?
For now, I have two txt files in my assets. One contains data in UInt8 format and another in UInt16 format. Both of them are of the same wav file. I need to create a wav file from the UInt16 file and UInt8 file is just for references.
Wav file from…
0
votes
1 answer
Split uint32 into two uint16
How does one go about splitting a single uint32 var in Go into two uint16 vars, representing the 16 MSB and 16 LSB respectively?
Here is a representation of what I am trying to do:
var number uint32
var a uint16
var b uint16
number =…

Atif Ali
- 2,186
- 2
- 12
- 23
0
votes
0 answers
How do I get simple UInt16 arithmetic to work?
I've got some incredibly simple code. Three UInt16 variables. I can do simple assignments but it won't let me do simple arithmetic.
Here's the code
UInt16 A = 1; // This is OK
UInt16 B = 2; // This is OK
UInt16 C = A * B; // Does NOT…

Roger Garrett
- 349
- 1
- 7
- 13
0
votes
1 answer
How to convert UINT16 into two signed chars?
I'm doing this conversion is because from a network where the data being received is an array of unsigned char[8]. Every two bytes represent a UINT16 number. I want to send these bytes through a socket however, sockets require the chars to be signed…

the big pescado
- 40
- 7
0
votes
1 answer
Equivalent of BitConverter.ToUInt16 of C# for Java 7
My question is about Java.
I need a method that returns an unsigned 16-bit integer converted from two bytes at the specified position in a byte array.
In other words I need the equivalent of the method BitConverter.ToUInt16 of C# for Java that works…

Adalher2478
- 35
- 7
0
votes
1 answer
Equivalent of BitConverter.ToUInt16 of C# for Java
My question is about Java
What is the equivalent of BitConverter.ToUInt16 for Java?
I am trying to translate this method of C#:
public static implicit operator ushort(HashlinkReader p)
{
ushort tmp =…

Adalher2478
- 35
- 7
0
votes
0 answers
Reading Big-endian, uint18 binary file with Python3
I have some weird problem while reading file with Python3.
With Matlab I have code
fid = fopen('histograms_testi.bin','r');
data = fread(fid,'*uint16','ieee-be');
fclose(fid);
%reshaping
data = reshape(data,4096,numel(data)/4096);
where the…

mamark
- 3
- 3
0
votes
2 answers
Converting uint8_t* buffer to uint16_t and changing endianness
I'd like to process data provided by an external library.
The lib holds the data and provides access to it like this:
const uint8_t* data;
std::pair getvalue() const {
return std::make_pair(data + offset, data +…

Daniel
- 2,318
- 2
- 22
- 53
0
votes
2 answers
counting sort of binary file in C, containing only uint16_t numbers
I'm struggling with the following task: write a C program which takes two parameters: input.bin and output.bin.
input.bin and output.bin are binary files
input.bin can contain max 65535 uint16_t numbers
file output.bin must be created by the…

fastAlgo
- 83
- 6
0
votes
3 answers
Converting an IPV6 string to uint16_t array in C++
I have an IPV6 string as an example below :
"0001:0002:0003:0004:0005:0006:0007:0008"
I am trying to find the cleanest way to convert this into a uint16_t array of 8 values containing 1 - 8 .
I cannot use inet_pton()
I could create my own parsing…

Engineer999
- 3,683
- 6
- 33
- 71
0
votes
1 answer
Show array as Image from .tif file with values uint16
I have a .tif file from a CT scan which I want to visualize as an image. And later use for training a Convolutional Neural Network.
I would like to preserve as much as possible the original format.
import numpy as np
import tifffile as tiff
a =…

Boels Maxence
- 349
- 3
- 16
0
votes
1 answer
Little confused on subtracting uint16_t values
So i am trying to subtract two uint_16 values from one another and every time i do it i get an error.
conversion from 'int' to 'uint16_t', signed/unsigned mismatch
uint16_t a = 432;
uint16_t d= 60000;
uint16_t total = d -a;
I know you would…

Jay
- 31
- 8
0
votes
1 answer
Convert CBUUID to NSNumber in swift
How Can I convert a CBUUID to UINT16?
I want to procure the device information in the advertisement data as UINT16.
I am getting the error
Could not cast value of type 'CBUUID' (0x1d2715e68) to 'NSNumber' (0x1d25c9db0).
2019-12-04…

Denzil
- 415
- 5
- 13