Create binary image from compressed domain values in text file

1 回表示 (過去 30 日間)
Yousra Ashfaq
Yousra Ashfaq 2022 年 10 月 27 日
編集済み: Yousra Ashfaq 2022 年 11 月 21 日
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);

回答 (1 件)

Walter Roberson
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
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:
Yousra Ashfaq
Yousra Ashfaq 2022 年 11 月 21 日
編集済み: Yousra Ashfaq 2022 年 11 月 21 日
@Image Analyst I am working in video compressed domain. I am experimenting on both hevc and vvc. I have extracted features from their reference softwares and using those features I am trying to detect either background/foreground or moving objects. The number of bits extracted are high when there's movement and low when there's not much movement, thats why we were able to create an image using x, y coordinates and number of bits :)
If you have any suggestion on how to proceed with my problem, let me know :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by