How to create this image

i am new to opencv
can someone plz guide me how can i get similiar image from matlab commands from the .csv sheet
i have attached the file
i m using 2018a version

13 Comments

The csv contains length and width information but nothing about position and nothing about color. We need more to go on.
I should add that even though there is length and width information, it's not clear what "length" or "width" mean in this context. Excepting the specks, no objects (or parts of objects) in this image are remotely close to the sizes described in the csv file, nor does there appear to be any common scaling factor that would relate them.
prabhu singh
prabhu singh on 25 Jul 2022
Edited: prabhu singh on 25 Jul 2022
Sir,the figure I attached here just to show how I should get my final output using open CV tools..
Color of outer rectangle- black Inner rectangle- -white Position-centre of the page
you have four length and width pairs in the file. You have two rectangles in the output image. Each rectangle needs to be specified by a corner position and a length and width. Your file does not appear to contain any corner position information.
DGM
DGM on 25 Jul 2022
Edited: DGM on 25 Jul 2022
This is what is known so far:
  • There are two rectangles
  • The rectangle geometry is defined by the numbers in the CSV file
  • The rectangle position is implied by the centering constraint
If there are two rectangles, then why are there four length/width pairs? If only two are used, which two? Just the first two?
These numbers are given as "length" and "width", which is ambiguous. "Length" merely implies the size of the longest side. Which is the vertical? Is width horizontal? If the diagram misrepresents position and scale, should I assume it also misrepresents orientation?
The rectangles are "centered" on the page -- but what size is the page? Any given size? If the height/width of the page is odd, how do you propose to center a rectangle of even height/width?
outer rectangle 10 mm ,black
inner rectangle 6 mm white
width 2mm
i have tried to explain with an example
your file contains
Length,widh
10,5
15,6
20,4
12,7
Is that outer rectangle 10 inner 5? If so then how is the 15, 6 to be placed relative to the 10, 5? Is the desired output a cell array of data matrices?
i wanted to create 4 rectangles will be created from this file
You want to create four figures, each with an image displayed? You want to create one figure with four subplots each of which displays one image? You want to create one axes that displays four rectangles that are piled up on each other so that the black outer rectangles merge together? You want to create one data array for each line in the file, dynamically creating variable names? You want to create a cell array of data arrays? You want to create one GIF file for each line of the input file?
DGM
DGM on 25 Jul 2022
Edited: DGM on 25 Jul 2022
So the rectangles aren't centered on the page? If they aren't centered on the page, then where are they? Are they in the NW corner? Are they against the edge as in this example, or are they offset as in the other example?
If the outer rectangle is 10mmx10mm and the inner rectangle is 6mmx6mm, am I to assume the diagram is wrong, because that says it's 3mmx3mm. What do any of the numbers in the CSV file have to do with these new numbers?
How do millimeters relate to anything in image coordinates in pixels? We still don't know how big the image is.
Again, if you want 4 rectangles, then which coordinates correspond to which rectangles? If each pair of rows in the CSV file correspond to an inner and outer rectangle respectively, then the second pair is in opposite order. Are the rectangles even drawn in pairs in separate images? Is there something else that involves all 4 rectangles in one image?
Or is each row in the CSV representative of a pair of rectangles? (i.e. [10 6] denotes a 10x10 black rectangle and a 6x6 white rectangle). Is it safe to assume that these are indeed supposed to be squares?
If you're trying to print this on a page, then generating the rectangle images should be simple, but I have no idea how you'd mangage to programmatically beat MATLAB into printing the image at a particular size. AFAIK, everything has to be rendered as a figure, at which point keeping control of the relative size of things turns into a giant mess.
Also bear in mind that most printers can't print up to the image edges, so you'll have to find the edge of the printable area if you want it in the corner.
Size of a printed image when print() is used, depends upon the figure PaperPosition properties.
Every time I've tried to do that, it seems that the PaperPosition is controlling the figure position, but the image is much smaller, since the axes has padding. I don't think I ever managed to wrangle a means to do it programmatically that actually worked consistently. I can get it to work using the GUI, but I'm assuming a programmatic approach is desired.

Sign in to comment.

Answers (0)

Tags

Asked:

on 23 Jul 2022

Commented:

DGM
on 26 Jul 2022

Community Treasure Hunt

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

Start Hunting!