Pixel Manipulation with C++ [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I want to take an image in jpg format, split it up in pixels and then manipulate those pixels (duplicate them, change their position etc..)
Of course I'm not asking for the code :-) but the tools to do it. I am newbie in programming.
I know nothing about reading from an image, manipulating and outputing it. Do I need special libraries to import? Special commands to use in order to manipulate the image?
What I want to do is experiment with zooming a jpg to infinity by manipulating the number and position of pixels.

There are a few libraries that can be used for manipulating images. I recommend ImageMagick (see documentation for the C++ interface), but there's also DevIL.
Using ImageMagick, all the details are hidden from you, and manipulating the pixel data can be as simple as in this example:
Image my_image(); // create an *empty* image using the default Image constructor
my_image.read("picture.jpg");
my_image.pixelColor(50,50,Color("red")); // set the pixel at position (50,50) to red
my_image.write("saved_picture.jpg");

You can use CImg Library, Also you might find something on this list

Related

Using homography for a virtual monitor [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm currently working on a project where I need to create a virtual screen for feedback during a game
My program draws an image at a tracked position. What I wan't it to do is to have this image follow my 4 tracked points, so it scales and rotates.
What I need for this is to get the homography to work, and I'm sorry to ask this question, because I know there's a lot of different articles, and I've been trying to go through quite many of these, but they don't make much sense to me. The issue i'm facing right now is that I don't know how to.
I can get it to scale the texture or the content of the image but it remains the same format of height and width. It doesn't rotate it, right now since I don't have a update function for it yet, which I don't know how to create either. I need it to stretch the picture itself so it scales accordingly to the points tracked.
With this post I hope you can help me in the right direction for just scaling the format of my image accordingly, that would be a major break-through for me.
I'm using openframeworks with openCV and ofxCV addons in Codeblocks (C++) on windows 7.
There's some functions in the addons of ofxCv, I'm pretty confused about:
For instance, I have not much idea of how the "imitate();" works and what it does.
This neither:
"homography = findHomography(Mat(dstPoints), Mat(srcPoints);"
and the: "warpPerspective(origImg, warpImg, homography, CV_INTER_LINEAR);"
I'm not sure I'm using these correctly, and have had difficulties finding proper documentation on these, that makes sense to me.
Another thing I have doubts about, is the usage of matrices in regards to this task.
As you've propably already figured out, I'm really not an experienced programmer. Any help in the right direction would be much appreciated!
This is a paste of all of the code: http://pastebin.com/MFfJqGZ1
The most interesting part, or where I personally believe I'm missing something or have done something wrong is between line 199-223.
And heres the header file: http://pastebin.com/XfQySAmh
Thanks so much in advance
Best regards
Jesper

Draw text around circle with C++ MFC functions [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have problem with text drawing around Circle.
I found great sample in C# http://www.codeproject.com/Articles/30090/Text-On-A-Path-in-WPF
Bu I need to implement this in VC 6.0 and C# sample isn't working for me for that reason.
Maybe exist some basic algorithm to implement this?
All drawings must be drawn in CDC.
CDC is a thin wrapper around GDI. GDI doesn't provide much support for what you want to do, so it will be a lot of work. Here are a couple of approaches:
Draw the text normally (in a straight line) to an off-screen DIB section, and then do a pixelwise transformation to make another off-screen DIB section with the text in a circle. Then you can blit the transformed DIB section to the output device.
For each character, create a logical font with the escapement and orientation set to the appropriate angle for the current position, then draw the character with that font. Repeat for each character. The problem here is that, even with TrueType or OpenType fonts, the rotations aren't always very good, depending on the quality of the font, hinting, etc.
Use a TrueType or OpenType font and get GDI to give you the vectors (line segments and bezier curves) that define the actual character shapes. Assemble these into a straight row, and then apply a Cartesian to polar coordinate transform. Draw the result using one of the path functions.

Create a 2D world [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Ive got a project for school that is to create the tanks game ( like worms or something else )
With a little research I found that the best way to create the 2D world would be to hold a bitmap of 1 and 0 to switch between background and foreground. So that I could load 2 images one for the background like the worms game the sea or something and another image with the map that is placed on it. Now because of that bitmap if I shoot something I could simply replace a 1 in a 0 so that there is a whole in the map..
With QT I could then just draw a canvas where I could display that bitmap.
I just don't find how to program this, maybe someone could help me out, where to start?
What you're describing with the 1's and 0's is called transparency and bitmaps can be made to encode this information in them, usually known as the alpha channel.
The key is to break down the problem into smaller parts and then tackle each small part - your question is very broad. So, break it down like this:
Create a window
Draw a bitmap on the window (no transparency - it's the background)
Draw a second bitmap with transparency
Modify transparency of second bitmap at run time
Although I think the qt is not the right tool for that, you can start with Graphics View Examples. That should give you a quick start.

Reading a black-and-white image as 0's and 1's [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
How can I read a black-and-white image file as ones and zeros? I'm using VC++6, OpenCv, and the FANN (Faster Artificial Neural Network) Library.
The pixel data in an image file is represented in a format. There are may different methods for organizing pixel data in a file: TIFF, JPEG, GIF, PNG, BMP, etc., just to name a few. Need more information about your file before detailed help can be given.
All data in a file is made of ones and zeros, just the nature of the computer world. Perhaps if you indicate what you are doing with the image data, more information can be presented.
See the following:
Wikipedia page on image formats.
std::ifstream::open, binary mode.
std::ifstream::read
std::vector to hold
the data.
Search Stack Overflow for the keywords "read binary file".
Open the file. Read each pixel's color value, and interpret a white pixel as a 1 and a black pixel as a 0.
If you expect me to write this program for you, I bill out at $250 US per hour.

How to create this desktop recorder? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I want to create a desktop recorder that require very little HD space.
It should capture the current display into a buffer, compare it to the previous state, and save only the rectangles that differ to the previous state.
What API, function or library I have to use ?
Well if you want to save the differences from each frame to frame only you could simply use a substraction-method. Simply substract the color values at image(t+1) from image(t)... All parts that stay equal haven't changed... only the parts that are different will result in something non-zero. You can then extract the rectangles around it and save them. But of course be aware since there might be more than one part changing of course and you probably wanna save each one instead of the big rectangle that contains all changes...
You could use OpenCV for this... it has all basic functions for image substraction, rectangle fitting, cropping, ...
Hope that helps...
Consider using Windows Media Screen Capture encoder for the task. You will feed your captured frames to it, and it will do the rest and create highly efficient wmv file for you.