Page 1 of 1

[c++] need some help

Posted: 2012-04-11T16:50:13-07:00
by Murderface
Hi I try to create a voronoi diagram with IM inside my c++ program. I have a lot of difficulties...

my incudes :

Code: Select all

#include <Magick++.h>
#include <MagickCore.h>
#include <string>
#include <iostream>
#include <list>
my try:

Code: Select all

std::string backGround = "xc:#ffffff";
Magick::Image img_d;
MagickCore::Image *_Image_d;
img_d.size("100x100");
img_d.texture( backGround );
const MagickCore::ChannelType channel=MagickCore::RGBChannels;
double l_doubles[] = {   
	30,10, 1,0,0,
	10,80, 0,0, 1,
	70,60, 0,1,0,
	80,20, 1,0,0
};
Magick::Image img_e;
img_e = MagickCore::SparseColorImage(img_d.image(),channel ,MagickCore::VoronoiColorInterpolate, 20,l_doubles ,exception);

img_e.display( );
1) I realized that I store MagickCore::SparseColorImage in a Magick::Image and not a MagickCore::Image object. Are they identical ? I get no error
2) I get a blank picture when I display, I don't understand wth...
3) about the ChannelType what is the DefaultChannels, what happens when using UndefinedChannel. In my case I tried to changed the channel. Example, by using this

Code: Select all

const MagickCore::ChannelType channel=MagickCore::AllChannels ;
I got an error at the execution :
a.out: magick/display.c:1657: DisplayImages: Assertion `images != (Image *) ((void *)0)' failed.
Abandon
I think this API isn't up to date :
http://www.imagemagick.org/api/MagickCo ... a3d9e3034a
because I watched the code of IM on my computer (downloaded last night) SparseColorImage need the ChannelType...

you have a lot of documentation full of examples about the uses of IM, and nothing about the uses of MagickCore...

I started with Magick++, but now I don't understand what's the reason to use Magick++ I still calling MagickCore. so what can does Magick++ that MagicCore can't ?

Re: [c++] need some help

Posted: 2012-04-11T20:45:59-07:00
by anthony
MagickCore image and MagickWand are not the same.

Their is a magick wand function to extract the current image pointer from a magick wand.

But you also can use MagickSparseColorImage()

What is missing is a function to convert a string with coordinates and colrnames into the floating point array.
Something I originally added to the MagickCore, but was 'moved into the CLI interface only, and thus not available
to MagickWand API or other API's as I originally intended.

Re: [c++] need some help

Posted: 2012-04-11T21:21:39-07:00
by Murderface
anthony wrote:MagickCore image and MagickWand are not the same.

Their is a magick wand function to extract the current image pointer from a magick wand.

But you also can use MagickSparseColorImage()

What is missing is a function to convert a string with coordinates and colrnames into the floating point array.
Something I originally added to the MagickCore, but was 'moved into the CLI interface only, and thus not available
to MagickWand API or other API's as I originally intended.
why are you talking about MagickWand ? I didn't use it, I don't want to use it

Re: [c++] need some help

Posted: 2012-04-12T00:23:00-07:00
by anthony
Sorry. I saw Magick::Image and assumed that was the case.
Applogies. :oops:

I'll be quite now as I am not that faimlar with C++ interface :-(


How even the number of floats need for a color is variable.
It depends on no tonly the channel setting, but also in if channels are present in the image.
Default channels is RGBKA so if your image has no K channel (it isn;'t CYMK) and you do NOT have a alpha channel, then you need RGB channels only.

That seems to be the case here.

Have you check the exceptions for errors? That would be the next thing to try.

Re: [c++] need some help

Posted: 2012-04-12T09:11:59-07:00
by Murderface
anthony wrote:Sorry. I saw Magick::Image and assumed that was the case.
Applogies. :oops:
no problem
anthony wrote:How even the number of floats need for a color is variable.
I think color range here is between 0 and 1, I'm pretty sure of that.
anthony wrote:It depends on no tonly the channel setting, but also in if channels are present in the image.
Default channels is RGBKA so if your image has no K channel (it isn;'t CYMK) and you do NOT have a alpha channel, then you need RGB channels only.
now, I don't know how to add a new channel, and moreover since I have RGB channels that doesn"t explain why I don't get the voronoi.
anthony wrote:Have you check the exceptions for errors? That would be the next thing to try.
I would like, but for now I don't now how to read the exceptions.... I'm using IM for 2 days only.

Re: [c++] need some help

Posted: 2012-04-12T22:35:58-07:00
by Murderface
UP
I'm still not able to get my voronoi. I need help...

Re: [c++] need some help

Posted: 2012-04-13T07:09:57-07:00
by anthony
Murderface wrote:
anthony wrote:How even the number of floats need for a color is variable.
I think color range here is between 0 and 1, I'm pretty sure of that.
Yes the value range is 0.0 to 1.0 (or more if you don't mind clipping).

But what I ment was the actualy number of floating values per color, 3 for RGB, 4 for CMYK, or 4 for RGBA with a -channel setting of RGBA and a image with alpha enabled. It is actually rather complex.
anthony wrote:Have you check the exceptions for errors? That would be the next thing to try.
I would like, but for now I don't now how to read the exceptions.... I'm using IM for 2 days only.
Hmmm, can you give use a example image? I'll try it using command line (yes -sparse-color on command line can use a purely floating point value list without using color names, so I can then check and see what happens.

This however works fine...

Code: Select all

convert -size 100x100 xc: -channel RGB -sparse-color Voronoi '30,10, 1,0,0,
   10,80, 0,0, 1,
   70,60, 0,1,0,
   80,20, 1,0,0' show:
so it should be correct for you.

Re: [c++] need some help

Posted: 2012-04-13T09:55:45-07:00
by Murderface
I know that work with convert program... this is not the question here.
I'm totaly stuck... damn! nobody can help me ?

Re: [c++] need some help

Posted: 2012-04-15T01:41:11-07:00
by anthony
Unfortunatally I am not a c++ programmer, though I can program in C.

As far as I can see it should basically work.

Without seeing the exception, it is imposible to say what is going wrong.
Look for a CatchException() type function to print the exception.