Developing an image frame sequence generator in MATLAB - image

I am doing a project where I have to create frames of images, to show a track path of an object and detect it. The end goal of my code is to create a line that shows the track path of the object as it moves and a box to detect the object at it's final position on the image (original image and desired output image that I would like is shown as an example).
In order to do this, I need help with generating the frames with different object positions. I have already created an object from an array (using the zeros function) with a set intensity value and have overlayed it on to the original background image (using imadd(image, object)). I have different frames with the object at different positions. Any idea, how I can show a streak/line to show the track path of the object?
I would really appreciate any help with this.
Kind regards,
Vanessa
P.S. This is the how original data looks like:
1]
And this is the desired output:

Related

where have i miscalibrated my bitmap (.bmp) image file?

Im 15 and a newbie trying to learn more about image storage. I wrote a script in python to create a bitmap image without any imports. Im familiar with PIL/PILLOW, im not using any imports simply to learn more, as they will not help explain images at a binary level. my issue is that when i try to draw to the image, it gets distorted. For example, the code I've attached should draw out straight rows of black and white lines, but on the image it generates (attached as a png as SO won't attach a .bmp), there are fault lines where the image goes askew.
#The header contains all the metadata of the file, so that it can be scanned and displayed correctly.
#I've attached details of this header to my question
header=[b'\x42',b'\x4d',b'\x18',b'\x31',b'\x0c',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x36',b'\x00',b'\x00',b'\x00',b'\x28',b'\x00',b'\x00',b'\x00',b'\x80',b'\x02',b'\x00',b'\x00',b'\xaa',b'\x01',b'\x00',b'\x00',b'\x01',b'\x00',b'\x18',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00',b'\x00']
#create a file to write the image to, in biinary.
#you may wish to change the file path
with open ("test.bmp","wb") as f:
#first write in the header
for i in range(len(header)):
f.write(header[i])
#now write in the pixel data
#640 is the image width
for x in range(0,640):
#426 is the image height
for y in range(0,426):
#if the row is an even number, make it a white pixel.
if x %2 ==0:
byte_arr=[255,255,255]
#else make it a black pixel.
else:
byte_arr=[0,0,0]
#write the pixel data bytes to the file
some_bytes = bytearray(byte_arr)
immutable_bytes = bytes(some_bytes)
f.write(immutable_bytes)
this article has been very helpful in clearly explaining the bitmap format.
[])
I have been able to change the number of fault lines by changing the number of rows, but i cannot get rid of them entirely. I suspect the problem is in the files meta-data, but ive checked through it and cannot find any bad data. I've attached a (slightly messy) breakdown of the header ive used, which the article also explains in more detail.

How can I create a pixel labelled image for Semantic Segmentation?

I am following the Semantic Segmentation Examples tutorial by MathWorks.
I understand that I can load pixel labeled images
pxDir = fullfile(dataDir,'buildingPixelLabels');
Define the class names.
classNames = ["sky" "grass" "building" "sidewalk"];
Define the label ID for each class name.
pixelLabelID = [1 2 3 4];
and create a pixelLabelDatastore.
pxds = pixelLabelDatastore(pxDir,classNames,pixelLabelID);
But, how do I create a custom pixel labelled image where every pixel value represents the categorical label of that pixel?
I would then proceed by writing:
pxDir = fullfile(dataDir,'myCustomPixelLabels');
If I understood correctly, imageDatastore holds the actual image and not the pixel labels for that image.
EDIT:
On my system pxDir points to 'C:\Program Files\MATLAB\R2017a\toolbox\vision\visiondata\buildingPixelLabels'. Since I am on Matlab2017a so this example is not included by default, and I cannot compare or view the file to get a better understanding of what I need to do to reproduce this example.
The answer can be found here.
Matlab 2017a
Go to the APPS tab, and search for Image Labeler, or Training Image Labeler
Click on Add Images to add your training images.
Click on Add ROI Labels to add class names for the regions of interest.
Proceed to select the regions of interest manually from the uploaded images.
Once areas are selected, the data can be exported to workspace as a Ground Truth object.

How to display calculation results in namedWindow in opencv (c++)

I used this code to display multiple images in the same namedWindow. Now I want to display some of the calculation results (that I have calculated before with image processing functions).
The results should be displayed in the fourth position of the namedWindow, like I show in the red square in the image below:
Is there any way in opencv that can throw console window in the namedWindow? Can I copy the results from console window in any other way on the named window? Is it possible to create somehow scrolling window with all information and put them on ?
I would suggest creating an new Mat with either ones() or zeros() and then using the function putText to insert your text.
Afterwards show the Mat like the rest before

How to find out the dimensions of a 3-D model constructed using an object file and the patch function onto the figure window?

I have attached the object file from which we are trying to find the dimensions(please open the objectfile.txt in notepad++ or sublime text as it groups the values into to rows and columns respectively). Using this object file we have plotted the image onto the figure window using Patch function. Now, what we want to achieve is to find the dimensions of the 3-D object model. We aren't able to find any useful links. The main purpose is to find the waist size and the shoulder length of the 3D model. Here's an image of the figure window.
How should we approach this problem? Is there any algorithm that we have to follow?Image of 3D model on figure window in matlab

Matlab create image from array and save without displaying

Apologies if this is a dupe, I've been searching for over an hour but the search terms are all really broad and I just keep getting the same results. Also I'm fairly new to matlab so apologies for any misunderstandings.
Anywho, I have a matlab program which needs to frequently save an image generated from a matrix, but I just can't figure out how to do that without displaying it first. Basically I'm caught in between two functions, image and imwrite, both only do half of what I want.
image is able to take my matrix and create the desired output, but it just displays it to a figure window
imwrite is able to save an image to a file without displaying it, but the image is completely wrong and I can't find any parameters that would fix it.
Other questions I've seen deal with using imread and managing figures and stuff, but I'm just doing (for example)
matrix = rand(20);
colormap(winter);
image(matrix, 'CDataMapping', 'scaled');
or
matrix = rand(20);
imwrite(matrix, winter(256), 'filename.png');
Is there some way to call the image function such that it doesn't display a figure window and then gets saved to a file? Something analogous to calling imshow and then savefig in matplotlib.
Just do this:
matrix = rand(20);
f = figure('visible', 'off');
colormap(winter);
image(matrix, 'CDataMapping', 'scaled');
print(f, '-dpng', 'filename.png');

Resources