Draw a matrix of numbers as an image with C++ [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a quite specific question: I want to draw a matrix of numbers in a greyscale image. The higher the number the brighter the output. Is there a way to do that in a C++ programme without having dependencies to a graphic library like Qt?
I looked through some examples of ImageMagick, but I'm not sure how to implement its functions in C++.
Answer
In case someone stumbles upon this question:
a modified code of the example shown here was a handy and easy solution

It's hard without a library. SFML seems easy to use.
EDIT
Also you have 3 other questions hidden in your question:
1- To save an image you can use sf::image::saveToFile
2- To get brighter number for higher number: You need to normalize your numbers to [MinColorYouWant MaxColorYouWant] (for example: [128,255]). Thus the normalization value corresponding to each number will become the color of the number.
3- SFML uses RGBA images by default. Just set the RGB channels equal to make it look greyscale.
EDIT 2 : I've fixed the example normalization from [128,256] to [128,255].

Related

How to detect teeth using opencv [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am working on one project and in that i want to make teeth white. So for that need to find teeth part.I have tried equalizeHist, adaptiveThreshold, threshold,dilate, erode etc.But not getting exact teeth part.
So can anyone tell me how can i do it.I am using OpenCV c++ library.
In input i have this image
I have found this type of mask
So if i use this mask the image looks unnatural like this,
I see two problems. You find the correct region, but the boundary is imprecise. That's solvable by looking at the gradient of the hue, which will form a clear contour. If you use the HSL color model, the Lightness component will likely have a sharp contrast too.
Secondly, the bigger effect IMO is that you far overdo the whitening. This loses a lot of contrast between teeth. You probably want to just drop the yellow saturation, but don't touch the luminosity.
If you want to be really fancy, determine where the teeth edges are, and you can smooth out the luminosity elsewhere. This removes small stains on teeth.

How to segment the actual human body shape from an image? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
As per my requirement, from single image of a dressed human (say wearing pant and shirt) with clear and plain background, Which algorithm can draw outline of an human body shape for only the pose given in the image. I am using opencv c++ library. All I can hear for now, is grabcut and contours but they only draw outline around the outfit but I need outline around inside body shape after eliminating outfit. Any algorithm to achieve this?
There are many examples in internet,generally speaking we often use the HOG descriptor to detect pedestrian you can search some information about
HOGDescriptor::setSVMDetector
HOGDescriptor::getDefaultPeopleDetector()
here is a simple sample code about you request:
enter link description here

reading black and white pixels as an array from jpeg in c and c++ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
im trying to learn how to read a jpeg image as an array of pixels in c++ or c. so far ive learned that i have to include a outside library such as libjpg.h.
ive been told that the jpeg is formated in a RGB structure where each pixel gives 3 values. is this true? and if so how would i read values for a purely black and white image?
the purpose of this question is that i am trying to assign a pointer to the top right corner of a white squre in a black picture.
if someone could show me how to read out the vaules that are given to me for this situation so i could assign this pointer i would be greatful.
Let's suppose you run with libjpeg. You'll allocate a buffer and then call jpeg_read_scanlines a sufficient number of times to get all of your decompressed image data into memory. You can read scanlines (rows) individually and reformat them as needed. If the image is grayscale, the RGB values will all be equal, so you can just read one of them.
Paul Bourke's site has some pretty good usage examples of libjpeg.

Using pixel colors for artificial neural networks [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to try and make a program that can identify pictures. Since I'm using the pixel colors as input, should I have 3 inputs for each pixel in the image? (RGB values)
Color images are normally defined by at least three channels: R(red), G(green) and B(blue). You may also have alpha and all sorts of other channels. So yes, for one pixel you will have 3 inputs.
You have to clarify what exactly "identify pictures" entails.
"Identify pictures" is a very vague term.
You might want to take a look at something like OpenCV for handling image data. Within that library, the Mat structure provides very transparent pixel storage and access.
As far as semantics go, the function doing the "identification" would ideally accept an image object as an input, as opposed to image channels.

Converting text to mesh [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I need to convert text (string+font) into mesh (vertices, indices, triangles etc), but I don't need to draw anything. I'll just get a string from one API and push it as vertices & indices to another. What's the simplest/easiest/best way of doing this? Font metrics and text placing are of course available and no other transforms are needed.
I'm currently working with VC++. However, any kind of OpenSource (C/C++, C#, VB,...) and "non-open but free" COM/.NET -libraries would be great.
I've heard of FreeType. Does it answer my prayers or is there something even better?
EDIT: As Nico Schertler commented, there seems to be Mesh.TextFromFont -function in DirectX -libs that probably does the trick. Thank you Nico! I'll update when I have time to test this in practise.
Mesh.TextFromFont sounded good but it didn't save the day since I couldn't figure out how to get the actual point/triangle data from the mesh -object.
But then I found this. In this project, GraphicsPath is used to create a point-path from a glyph. Then the points are coverted into Polygons and the polygons are then tesselated into triangles using Poly2Tri.
A quick browse through the source code and with some small modifications and code stripping I ended up with a nice .NET -dll with one simple static function that does everything I need.
To convert a text into a mesh you can use the ttf2mesh library. This library consists of just one C-file and allows to open truetype font (.ttf) and convert it glyphs to a mesh objects in 2d or 3d space. There is an examples in the repository.
An interesting feature is the lack of dependency on any third party library (like libfreetype). Also in the examples there is a ttf2obj program that allows you to convert a font file to an OBJ file.