Page 1 of 1

"irregular channel geometry" error joining files

Posted: 2012-05-04T12:17:08-07:00
by jkimble
I've got two 1920x540 (1080p) j2k (JPEG 2000) images that are the upper and lower halves of a full 1080p frame. I need to stitch or join these two images into a single 1080p frame within a C program (reading raw data from a camera and doing some preprocessing). I have two issues (at least...)

1) I have no example or guide as to how to do this with Image Magic. I've done it with other image formats in Java using the imageIO classes (Image Magick too?) but if I could get an example or outline of how to do this with the MagickWand C API I would very much appreciate it.

2) Using the "convert" routine to do this from the command line I always get the error: "irregular channel geometry not supported" for both input files. I'm just doing: "convert file1.j2k file2.j2k +append joined.j2k" from the command line (Fedora 17, 64 bit). I'm pretty sure I'm going to get the same error working with the Wand C API so I really need to get to the bottom of this.

Any help or suggestions would be GREATLY appreciate.

Thanks!

Re: "irregular channel geometry" error joining files

Posted: 2012-05-04T13:38:18-07:00
by fmw42
I am not sure IM supports .j2k.

convert -list format

J2C* JP2 rw- JPEG-2000 Code Stream Syntax
JNG* PNG rw- JPEG Network Graphics
See http://www.libpng.org/pub/mng/ for details about the JNG
format.
JP2* JP2 rw- JPEG-2000 File Format Syntax
JPC* JP2 rw- JPEG-2000 Code Stream Syntax


try .jp2 in your command

convert file1.jp2 file2.jp2 +append joined.jp2

or

convert JP2:file1.jp2 JP2:file2.jp2 +append JP2:joined.jp2

Before you do that, do you know that you have the Jasper delegate library installed.

Try

convert -list format

and see if you have those file formats listed above.

Or try

convert -list configure

and look at the line starting with DELEGATES and see if it includes jp2

Re: "irregular channel geometry" error joining files

Posted: 2012-05-04T13:40:36-07:00
by el_supremo
Give this a try:

Code: Select all

#include <windows.h>
#include <wand/MagickWand.h>
void test_wand(void)
{
	MagickWand *mw = NULL,*mwa;

	MagickWandGenesis();
	mw = NewMagickWand();
	MagickReadImage(mw,"logo:");
	MagickReadImage(mw,"logo:");

	MagickResetIterator(mw);
	// Append the second image to the bottom (MagickTrue) of the original image
	mwa = MagickAppendImages(mw,MagickTrue);

	// and save the result
	MagickWriteImage(mwa,"logo_append.png");
	if(mw) mw = DestroyMagickWand(mw);
	if(mwa) mwa = DestroyMagickWand(mwa);
	MagickWandTerminus();
}
Pete

Re: "irregular channel geometry" error joining files

Posted: 2012-05-05T11:11:30-07:00
by jkimble
Thanks to both of your replies. I do have the IM libs installed but there's no j2k support. It's odd because there is j2c support which is the other JPEG2000 streaming format. I'm not sure what the difference is.

The other thing I take from this is that jp2 is supported. I can convert my j2k images to jp2's because these are simple files with unform color and bit depth so adding a header is easy. I can then do the stitching as Joe described (thanks again!) and then strip the header back off the new image (I need the j2k's to create a motion JPEG). It's clunky and maybe too slow but it'll work which is more than I have right now.

I've another suggestion from another board describing how to join the two files manually. It's tricky and I'll have to understand more about the file format than I wanted to but if the above is too slow I'll just have to do it.

Thank you both again!

Re: "irregular channel geometry" error joining files

Posted: 2012-05-05T11:43:34-07:00
by fmw42
See http://www.eprintdriver.com/help/v5.0/A ... JPGFmt.htm for some info about j2k vs jp2

You might inquire in the Developers forum about support for j2k. IM uses the Jasper delegate library for jp2, but I do not know if it supports j2k. So you might inquire.

Re: "irregular channel geometry" error joining files

Posted: 2012-05-08T21:12:11-07:00
by anthony
C programming in IM Examples, is quite straight forward. Anything that you see done on the command line is available in the MagickWand API, or you have the lower level Core library.

However by joining do you mean just appending, or actually aligning and 'stitching' together, to match up shared parts.
As you talk about a camera probably the latter.