Drawing lines with boost::gil? [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 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.

Related

Massively struggling with laying out DirectX and windows [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 have managed to get this example to work:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd370994(v=vs.85).aspx
My problem is that I am trying to structure the code there into something more understandable...
My first step is to remove all the stuff that's not absolutely necessary to lanching a window with a direct x surface... but as soon as I start messing with the code, I get massively confused at which components are core, and which are not...
Do you know of a kind of boilerplate project with literally the utmost basics in it for a directx surface in a window.
D2D is fine unless you suggest I just code straight in D3D... even though i'm only going to be drawing 2d stuff.
I've read so many resources and tutorials for directX but every blooming one has different bits and bobs placed in and it's so difficult to just learn what the "must" bits are!...
Just to help you with the question.
I have started by trying to create a Gfx object that will start and create surfaces and resources for direct X, I also tried to separate my windows code but ofcourse got a bit lost there too... Finally I wrapped up my Game class so that the windows loop just ran begin draw, render and end draw. in the tutorial above you have 2 brushes which as i'm not familiar with directX, I'm unsure if I can just whip them out completely or what?
I guess a step in the right direction is really what i'm looking for.
I very strongly suggest that you get hold of a decent book that can guide you through the steps:
For example - try to get a copy of this

Graph editor on Qt [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 writing a graph editor now. The programs must be written on Qt, but the problem is that I don't have enough experience with Qt, but I'm little experienced with C++. Last weeks I read one book about Qt, but I've read about 100 pages, so I know only some basics.
Can somebody give me advices about what classes should I use, please?
What I've already done:
I filled menubar with menus File, Algorithms, About etc.
I suppose that graph vertexes etc I should draw on QGraphicsView, so I added it too, also I add QGraphicsScene and bind them together (ui->setScene(scene)).
Sorry for my mistakes, unfortunately I don't have a complete understanding about all these things.
Also I added QGraphicsRectItem with scene->addRect() and set the flag moveable. But I don't know what classes should I have to use.
So, in general I want to understand how to do next things:
I want to add a panel with 2 buttons (vertex, line). After I chose vertex button (or what it will be) and click on the QGraphicsView - vertex should appear at that point. Also I must be able to change vertex name
After I chose line mode (link, which connected 2 vertexes) I should be able to connect 2 vertexes together depending on graph type (oriented or not).
By clicking on link between vertexes I should be able to change the weight of link.
I think it would be enough for one question.
Sorry if the question is very simple or stupid.
Thanks.
Your question is rather broad so it's nearly impossible to answer it entirely. So instead, I'll offer a really good example you might go look at. This example does much of what you want and might be a good starting set of code to both look at as well as reuse.

How to render ocean wave using opengl in 3D? [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 to render ocean waves using opengl in 3D? Any reply will be welcome.
Edit:
Is there any source code that renders ocean waves but not using an other sdk or api? It's difficult to learn how render it by read OSG source code maybe. So any tutorials about it will be ok, it is very good that it attach the source code.
Christian (above) is right. Currently your question is very broad and difficult to answer. You might want to do some research yourself and then ask a more targeted question.
Start looking at shallow water equations for example. (I'm skipping full fluid simulations here for the moment) Or read Tessendorf's "Simulating Ocean Waves". Or have a look at Cem Yuksel's wave particles. Even if you don't end up implementing any of it, the references will be a good resource for you. Another one might be this collection of links.
Not really a clear answer, but give us more to go on and we can point you in a more specific direction.
Rendering realistic looking water is extremely difficult. Luckily there are tools to make it easier, like OSGOcean, which can render some quite impressive waves.

Watershed algorithm – CT Lung segmentation [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 am searching for source code to segment Lung in CT images using watershed algorithm. Please let me know if you find any website / source code.
Relevant algorithms:
morphological watershed method (Meyer)
modified watershed algorithm (Beucher, Meyer)
gradient descent or rainfall algorithm (Osma-Ruiz)
watershed immersion algorithm (Vincent-Soille)
Some Source code here
Wikipedia might help.
OpenCV library has the implementation of Watershed algorithm.
The Insight Toolkit is a comprehensive image processing framework for segmentation and registration of medical images.
There are many specialised algorithms for processing medical images, including the Watershed algorithm. Some of the examples are very similar to what you describe.
I strongly recommend reading the ITK Software Guide book before undertaking such a significant project.
Furthermore, it is very important to choose a library that correctly deals with medical images and the special attributes and requirements they have (for example, patient orientation, anisotropic voxels, etc). Most libraries do not handle these aspects correctly, while ITK has been designed from the ground up to support all the complexities of medical imaging applications.

Is there any free or commercal jpeg decode which is really fast [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 am using c++, libjpeg for decoding jpeg file.
I find it is not fast enough, is there any method to make it faster by setting some compile parameter?
or are there any other lib can open jpeg files more faster?
now it takes about 750ms to open a 4368 * 2912 4m jpeg image.
I wish this can be reduced to 150ms.
Many thanks!
Added:
IJL seems faster than libjpeg:)
The fastest way is not to decode it at all. Usually you can use a low-res preview first; that requires only the low frequencies. For a 546 x 289 pixel preview, you in fact only need the (0,0) (DC) component.
There's the Intel Performance Primitives which contains JPEG coding/decoding implementations
Also see http://sourceforge.net/projects/libjpeg-turbo/ for a drop-in replacement of libjpeg that uses SIMD instructions for a significant performance boost.
I use libjpeg from ijg. It's documented how to modify for your purposes, like coding/decoding in memory.
I think DirectX and libSDL can decode jpegs - although libSDL might use libjpeg for decoding.