Create binary image from compressed domain values in text file
조회 수: 1 (최근 30일)
이전 댓글 표시
These are the .txt and .csv files of one of the frame. I want to be able to create a binary image from this file, I have the index of the block, the width, height, x position, y position and total number of bits. I wnat to use total no.of bits as pixel intensity and create an image based on that. Convert that no.of bits column to 0s and 1s either by didving by the largest value or taking the logarithmic value and create the image. Please guide me on how I should proceed further :)
clear all;
clc
cutable = readtable ('frame1.csv'); % i,x,y,w,h,no.of bits
carray = table2array (cutable);
len = length (carray);
idx = carray (:,1);
w = carray (:,2);
h = carray (:,3);
x = carray (:,4);
y = carray (:,5);
b = carray (:,6);
댓글 수: 0
답변 (1개)
Walter Roberson
2022년 11월 18일
cutable = readtable ('frame1.csv'); % i,x,y,w,h,no.of bits
carray = table2array (cutable);
len = length (carray);
idx = carray (:,1);
w = carray (:,2);
h = carray (:,3);
x = carray (:,4) + 1;
y = carray (:,5) + 1;
b = carray (:,6);
maxx = max(x + w - 1);
maxy = max(y + h - 1);
img = zeros(maxy, maxx);
for K = 1 : numel(x)
tx = x(K); ty = y(K);
img(ty:ty+h(K)-1, tx:tx+w(K)-1) = b(K);
end
img8 = uint8(rescale(img, 0, 255));
subplot(2,1,1);
image(img8)
colormap(gray(256))
title('linear');
minb = min(b);
scaleb = log(b ./ minb);
img = zeros(maxy, maxx);
for K = 1 : numel(x)
tx = x(K); ty = y(K);
img(ty:ty+h(K)-1, tx:tx+w(K)-1) = scaleb(K);
end
subplot(2,1,2);
imgL = uint8(rescale(img, 0, 255));
image(imgL)
colormap(gray(256))
title('log')
It looks to me as if the x, y indexing is not correct
You indicate that the first column is the index, but you have multiple entries with the same index, such as
64,32,32,32,0,449
64,16,16,32,0,139
It looks to me as if the first four columns have to do with position and size. However you have entries such as
0,64,64,0,0,2316
and if we try to interpret those as x y w h or w h x y then we seem to encounter either x or h that are 0, which does not sound correct.
댓글 수: 3
Image Analyst
2022년 11월 21일
편집: Image Analyst
2022년 11월 21일
You aren't trying to track individual jockeys or horses with images like that are you? Because that would be nearly impossible. But start here:
참고 항목
카테고리
Help Center 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!