Automatically normalize a range of data into specific values.
Show older comments
The system I am working with collects brightness data from a LED that uses three brightness levels to encode binary data along with a clock. The data range is 0 - 255. My intention is extract binary values (along with the clock value) from this range automatically; is it possible to do so?
Example raw brightness data:
[20, 253, 253, 108, 109, 254, 253, 254, 17, 19, 253, 253]
Example working code:
% Normalize raw luminous intensity values into a binary and clock
% representation. (zeros, ones, and twos)
% Note: Equation parameters found through observation.
disp('Normalize data into zeros, ones, twos')
for i = 1:length(raw_data)
if raw_data(i) < 50
normalized_data(i) = 0;
end
if (raw_data(i) > 50) && (raw_data(i) < 200)
normalized_data(i) = 1;
end
if raw_data(i) > 200
normalized_data(i) = 2;
end
end
disp (normalized_data)
Output:
[0, 2, 2, 1, 1, 2, 2, 2, 0, 0, 2, 2]
Is there a way to decide the equation parameters programmatically? Currently, I am bringing up a graph of the raw_data and through observation I am deciding the range where the zeros, ones, and twos should fall.
edit
I should note that lows, mediums, and highs of the raw data vary depending on external conditions and leaving constants as parameters may cause problems in a finalized system.
Thank you.
Accepted Answer
More Answers (1)
Image Analyst
on 14 Oct 2013
0 votes
Try imquantize() in the Image Processing Toolbox - it's meant for this purpose.
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!