Interpolation of Matrix in 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 9 years ago.
May I know how can I do the interpolation for a matrix in C++?
Eg:
I have a 3x3 matrix
{0 0 0
0 1 1
0 0 1}
I wish to resize it to a 10x10 matrix using bilinear interpolation.
Any tips or references about this?

What you want to do is called image resizing using bilinear interpolation. Knowing that google is your friend. I would try using a C++ library for that purpose. This question covers all C++ imaging libraries: Fastest C/C++ image resizing library Any reasonable library should satisfy your needs.

In order to linearly interpolate between two things you need to embed (put) them in a common vector space and then "draw" the line between them.
I can't see a useful embedding of a 3x3 matrix and a 10x10 matrix in a common vector space...

Related

Creating minesweep in C++ using vector arrays [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.
So basically im trying to create the computer game minesweeper for uni. I got it working with arrays, but now i have found out i have to use vectors instead which i am completely helpless with. If any one could help me it would be great. Basically i want to use vectors to create a matrix that will get bigger after each round of the game is played. There will be three rounds, the first one starting with a 9x9 matrix, then 12x12 then 24x24. One of the arrays will be made up completely of X's and the second will have randomly generated mines hidden within it, along with any neseccary numbers that are touching the mines. Any help at all would be much appreciated and if there were little pointers in any code that is sent to help me understand it would be fantastic :)
Thanks
Why don't you use a vector of vectors, e.g.vector<vector<int>>? I'm not sure if this has performance issues. But it's just a simple game, so who cares?
It's pretty easy using vectors.
vector<vector<char> > map ( size, vector<char> ( size ) );
That creates a 2d vector of char's of size x size.
How you use it exactly depends on the structure of your game's code.

Drawing lines with boost::gil? [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 need to draw some lines on an (off-screen) image. I'd like to use boost::gil because the lib is already integrated in my project.
I want to draw a line from start to end point in a 2dim array
Can anybody give me a quick example how to draw a line using gil?
Thank you.
GIL itself is very much concerned with storage of images and pixels in various formats and converting between them... but no more than that. user1929959's answer is using a GIL extension which facilitates interoperability of GIL with OpenCV and then uses OpenCV's line drawing (but OpenCV doesn't come with boost so you'd need to add that into your project too).
For high quality antialiased line drawing AGG and Cairo might also be worth considering (although you'd need to figure out how best adapt GIL images to their own image buffer types). But if you just want basic one pixel wide lines, consult any basic computer graphics text for some Bresenham's line algorithm pseudocode which could be trivially implemented using pixel-setting.
First take a look on boost::gil tutorial. You can find an example in drawing test, from where can easily extract method to drawing line.

insert data in boost ublas matrix matlab style [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 would like to insert data in a ublas::matrix but in one line the same as Matlab just like this (or something similar):
model = [
0.0685 0.6383 0.4558 0.7411 -0.7219 0.7081 0.7061 0.2887 -0.9521 -0.2553
0.4636 0.0159 -0.1010 0.2817 0.6638 0.1582 0.3925 -0.7954 0.6965 -0.7795
0 0 0 0 0 0 0 0 0 0];
If you take a look at the boost documentation, here is a list of the constructors of the matrix class http://www.boost.org/doc/libs/1_51_0/libs/numeric/ublas/doc/matrix.htm#18Members
As you can see from this documentation, it does not appear that there is a means of doing what you want at the present time, so I would suggest (unless you receive a better answer) that you populate your matrix using loops. Matlab and C++ are distinct languages so you cannot assume that you will be able to access functionality in identical manners.

Histogram equalization implementation [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.
All resources that I have found a very different and I am not sure what I have to do.
Now I already got my histogram which was pretty straight forward, I also got my cumulative histogram
I don't know how I have to use this new histogram to get a better contrast in my image. It is a image from 0 to 255 -> black to white (Pseudo code would be enough)
I am not able to make this connection on my own.
ps: It's about the general idea.
High contrast images have gaps (zeros or near zeros), that appear on "left" and "right" (high and low) sides of histogram. Reduction of contrast can be achieved by remapping lightness values to a wider range.
Lets say on a histogram you have all values filled with 0 up until index=35 (histogram[35]) and then all 0 after index=200 (histogram[200]). Remapping of 35 to 0, and 200 to 255 and interpolation everything in between accordingly will reduce total image contrast.
To increase contrast, a reverse of the above should be applied, so that the histogram is "compressed" from low and high ends.

How can i render a tiled map with C++/SDL [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.
I want to render tiles to the screen from a text file. I have the random terrain generator working, and I can move the data from the text file to a 2d vector. What I'm having trouble with is understanding how to give those tiles the coordinates they need to be rendered at. How would I go about assigning each tile its own coordinates relative to the camera?
I suggest checking this lua tutorial on how create a tile engine in great detail. You'll learn much more then what someone will be willing to post here on stack. Tile Engines as you will see from this tutorial, requires more then just a few lines of code. After you learn it here, it shouldn't be to hard for you to translate it to sdl/c++. Just a thought.
Its a good starting place.