26 #if defined (HAVE_CONFIG_H)
40 #if defined (HAVE_MAGICK)
77 bool indexed = (img.classType () == Magick::PseudoClass);
87 else if (fmt ==
"PNG")
97 const_cast<Magick::Image&
> (img).attribute (
"PNG:IHDR.color-type-orig");
98 if (! color_type.empty() && color_type !=
"3")
125 && img.channelDepth (Magick::RedChannel) == 1
126 && img.channelDepth (Magick::GreenChannel) == 1
127 && img.channelDepth (Magick::BlueChannel) == 1
128 && img.channelDepth (Magick::CyanChannel) == 1
129 && img.channelDepth (Magick::MagentaChannel) == 1
130 && img.channelDepth (Magick::YellowChannel) == 1
131 && img.channelDepth (Magick::BlackChannel) == 1
132 && img.channelDepth (Magick::OpacityChannel) == 1
133 && img.channelDepth (Magick::GrayChannel) == 1)
152 output =
Range (value, value);
155 error (
"__magick_read__: unknown datatype for Region option");
160 static std::map<std::string, octave_idx_type>
163 std::map<std::string, octave_idx_type> region;
169 region[
"row_start"] = rows.
base () -1;
170 region[
"col_start"] = cols.
base () -1;
171 region[
"row_end"] = rows.
max () -1;
172 region[
"col_end"] = cols.
max () -1;
176 region[
"row_cache"] = region[
"row_end"] - region[
"row_start"] +1;
177 region[
"col_cache"] = region[
"col_end"] - region[
"col_start"] +1;
180 region[
"row_shift"] = region[
"col_cache"] * rows.
inc ();
181 region[
"col_shift"] = region[
"col_cache"] *
182 (region[
"row_cache"] + rows.
inc () -1) - cols.
inc ();
185 region[
"row_out"] = rows.
numel ();
186 region[
"col_out"] = cols.
numel ();
200 const Magick::ColorRGB
c = img.colorMap (
i);
201 cmap(
i,0) = c.red ();
202 cmap(
i,1) = c.green ();
203 cmap(
i,2) = c.blue ();
204 amap(
i) = c.alpha ();
212 template <
typename T>
219 typedef typename T::element_type
P;
233 T img = T (
dim_vector (nRows, nCols, 1, nFrames));
234 P* img_fvec = img.fortran_vec ();
250 imvec[frameidx(
frame)].getConstPixels (col_start, row_start,
251 col_cache, row_cache);
253 const Magick::IndexPacket *pix
254 = imvec[frameidx(
frame)].getConstIndexes ();
260 img_fvec[idx++] =
static_cast<P
> (*pix);
277 read_maps (const_cast<Magick::Image&> (imvec[frameidx(def_elem)]));
282 if (imvec[def_elem].matte () && nargout >= 3)
284 const Matrix amap = maps(1).matrix_value ();
294 alpha_fvec[pix] = 1 - amap_fvec[static_cast<int> (img_fvec[3])];
307 template <
typename T>
314 typedef typename T::element_type
P;
355 if (imvec[def_elem].depth () == 32)
358 divisor = MaxRGB / ((uint64_t (1) << imvec[def_elem].depth ()) - 1);
367 Magick::ImageType
type = imvec[def_elem].type ();
368 if (type == Magick::BilevelType && imvec[def_elem].matte ())
369 type = Magick::GrayscaleMatteType;
378 if (imvec[0].magick () ==
"PNG")
389 = imvec[0].attribute (
"PNG:IHDR.color-type-orig");
392 type = Magick::GrayscaleType;
393 else if (type_str ==
"2")
394 type = Magick::TrueColorType;
395 else if (type_str ==
"6")
396 type = Magick::TrueColorMatteType;
397 else if (type_str ==
"4")
398 type = Magick::GrayscaleMatteType;
404 if (imvec[0].matte ())
406 if (type == Magick::GrayscaleType)
407 type = Magick::GrayscaleMatteType;
408 else if (type == Magick::TrueColorType)
409 type = Magick::TrueColorMatteType;
419 case Magick::GrayscaleMatteType:
420 type = Magick::GrayscaleType;
423 case Magick::PaletteMatteType:
424 type = Magick::PaletteType;
427 case Magick::TrueColorMatteType:
428 type = Magick::TrueColorType;
431 case Magick::ColorSeparationMatteType:
432 type = Magick::ColorSeparationType;
445 case Magick::BilevelType:
446 case Magick::GrayscaleType:
448 img = T (
dim_vector (nRows, nCols, 1, nFrames));
449 P *img_fvec = img.fortran_vec ();
455 const Magick::PixelPacket *pix
456 = imvec[frameidx(
frame)].getConstPixels (col_start, row_start,
457 col_cache, row_cache);
463 img_fvec[idx++] = pix->red / divisor;
472 case Magick::GrayscaleMatteType:
474 img = T (
dim_vector (nRows, nCols, 1, nFrames));
475 T alpha (
dim_vector (nRows, nCols, 1, nFrames));
476 P *img_fvec = img.fortran_vec ();
477 P *a_fvec = alpha.fortran_vec ();
483 const Magick::PixelPacket *pix
484 = imvec[frameidx(
frame)].getConstPixels (col_start, row_start,
485 col_cache, row_cache);
491 img_fvec[idx] = pix->red / divisor;
492 a_fvec[idx] = (MaxRGB - pix->opacity) / divisor;
503 case Magick::PaletteType:
504 case Magick::TrueColorType:
506 img = T (
dim_vector (nRows, nCols, 3, nFrames));
507 P *img_fvec = img.fortran_vec ();
513 const Magick::PixelPacket *pix
514 = imvec[frameidx(
frame)].getConstPixels (col_start, row_start,
515 col_cache, row_cache);
519 P *gbuf = img_fvec + color_stride;
520 P *bbuf = img_fvec + color_stride * 2;
526 rbuf[idx] = pix->red / divisor;
527 gbuf[idx] = pix->green / divisor;
528 bbuf[idx] = pix->blue / divisor;
534 img_fvec += frame_stride;
539 case Magick::PaletteMatteType:
540 case Magick::TrueColorMatteType:
542 img = T (
dim_vector (nRows, nCols, 3, nFrames));
543 T alpha (
dim_vector (nRows, nCols, 1, nFrames));
544 P *img_fvec = img.fortran_vec ();
545 P *a_fvec = alpha.fortran_vec ();
555 const Magick::PixelPacket *pix
556 = imvec[frameidx(
frame)].getConstPixels (col_start, row_start,
557 col_cache, row_cache);
561 P *gbuf = img_fvec + color_stride;
562 P *bbuf = img_fvec + color_stride * 2;
568 rbuf[idx] = pix->red / divisor;
569 gbuf[idx] = pix->green / divisor;
570 bbuf[idx] = pix->blue / divisor;
571 a_fvec[a_idx++] = (MaxRGB - pix->opacity) / divisor;
577 img_fvec += frame_stride;
583 case Magick::ColorSeparationType:
585 img = T (
dim_vector (nRows, nCols, 4, nFrames));
586 P *img_fvec = img.fortran_vec ();
592 const Magick::PixelPacket *pix
593 = imvec[frameidx(
frame)].getConstPixels (col_start, row_start,
594 col_cache, row_cache);
598 P *mbuf = img_fvec + color_stride;
599 P *ybuf = img_fvec + color_stride * 2;
600 P *kbuf = img_fvec + color_stride * 3;
606 cbuf[idx] = pix->red / divisor;
607 mbuf[idx] = pix->green / divisor;
608 ybuf[idx] = pix->blue / divisor;
609 kbuf[idx] = pix->opacity / divisor;
615 img_fvec += frame_stride;
621 case Magick::ColorSeparationMatteType:
623 img = T (
dim_vector (nRows, nCols, 4, nFrames));
624 T alpha (
dim_vector (nRows, nCols, 1, nFrames));
625 P *img_fvec = img.fortran_vec ();
626 P *a_fvec = alpha.fortran_vec ();
636 const Magick::PixelPacket *pix
637 = imvec[frameidx(
frame)].getConstPixels (col_start, row_start,
638 col_cache, row_cache);
641 const Magick::IndexPacket *apix
642 = imvec[frameidx(
frame)].getConstIndexes ();
646 P *mbuf = img_fvec + color_stride;
647 P *ybuf = img_fvec + color_stride * 2;
648 P *kbuf = img_fvec + color_stride * 3;
654 cbuf[idx] = pix->red / divisor;
655 mbuf[idx] = pix->green / divisor;
656 ybuf[idx] = pix->blue / divisor;
657 kbuf[idx] = pix->opacity / divisor;
658 a_fvec[a_idx++] = (MaxRGB - *apix) / divisor;
664 img_fvec += frame_stride;
671 error (
"__magick_read__: unknown Magick++ image type");
685 Magick::readImages (&imvec, filename);
687 catch (Magick::Warning&
w)
689 warning (
"Magick++ warning: %s", w.what ());
691 catch (Magick::Exception&
e)
693 error (
"Magick++ exception: %s", e.what ());
700 static bool initialized =
false;
706 const char *static_locale = setlocale (LC_ALL, NULL);
711 Magick::InitializeMagick (program_name.c_str ());
714 setlocale (LC_ALL, locale.c_str ());
735 if (QuantumDepth < 16)
737 "your version of %s limits images to %d bits per pixel\n",
738 MagickPackageName, QuantumDepth);
757 #if defined (HAVE_MAGICK)
759 if (
args.length () != 2 || !
args(0).is_string ())
765 =
args(1).xscalar_map_value (
"__magick_read__: OPTIONS must be a struct");
769 std::vector<Magick::Image> imvec;
784 frameidx = indexes.
xint_vector_value (
"__magick_read__: invalid value for Index/Frame");
792 if (frameidx(
i) < 0 || frameidx(
i) > nFrames - 1)
797 error (
"imread: index/frames specified are outside the number of images");
807 const unsigned int nRows = imvec[frameidx(0)].rows ();
808 const unsigned int nCols = imvec[frameidx(0)].columns ();
812 if (nRows != imvec[frameidx(
frame)].rows ()
813 || nCols != imvec[frameidx(
frame)].columns ())
815 error (
"imread: all frames must have the same size but frame %i is different",
825 output = read_indexed_images<boolNDArray> (imvec, frameidx,
828 output = read_indexed_images<uint8NDArray> (imvec, frameidx,
830 else if (depth <= 16)
831 output = read_indexed_images<uint16NDArray> (imvec, frameidx,
834 error (
"imread: indexed images with depths greater than 16-bit are not supported");
840 output = read_images<boolNDArray> (imvec, frameidx,
nargout,
options);
842 output = read_images<uint8NDArray> (imvec, frameidx,
nargout,
options);
843 else if (depth <= 16)
844 output = read_images<uint16NDArray> (imvec, frameidx,
nargout,
options);
845 else if (depth <= 32)
846 output = read_images<FloatNDArray> (imvec, frameidx,
nargout,
options);
848 error (
"imread: reading of images with %i-bit depth is not supported",
856 octave_unused_parameter (
args);
857 octave_unused_parameter (
nargout);
869 #if defined (HAVE_MAGICK)
871 template <
typename T>
873 img_float2uint (
const T& img)
875 typedef typename T::element_type
P;
879 const P* img_fvec = img.fortran_vec ();
884 out_fvec[idx] = img_fvec[idx] * max;
891 template <
typename T>
893 bitdepth_from_class ()
895 typedef typename T::element_type
P;
897 sizeof (
P) * std::numeric_limits<unsigned char>::digits;
904 const Magick::ImageType&
type,
905 const Magick::ClassType& klass)
907 Magick::Image img (Magick::Geometry (nCols, nRows),
"black");
911 img.classType (klass);
915 img.depth (bitdepth);
918 case Magick::GrayscaleMatteType:
919 case Magick::TrueColorMatteType:
920 case Magick::ColorSeparationMatteType:
921 case Magick::PaletteMatteType:
932 template <
typename T>
934 encode_indexed_images (std::vector<Magick::Image>& imvec,
938 typedef typename T::element_type
P;
947 std::vector<Magick::ColorRGB> colormap;
953 colormap.push_back (Magick::ColorRGB (cmap_fvec[map_idx],
954 cmap_fvec[map_idx + G_offset],
955 cmap_fvec[map_idx + B_offset]));
961 Magick::Image m_img = init_enconde_image (nCols, nRows, bitdepth,
963 Magick::PseudoClass);
966 m_img.colorMapSize (cmap_size);
968 m_img.colorMap (map_idx, colormap[map_idx]);
979 Magick::PixelPacket* pix = m_img.getPixels (0, 0, nCols, nRows);
980 Magick::IndexPacket*
ind = m_img.getIndexes ();
981 const P* img_fvec = img.fortran_vec ();
988 ind[GM_idx] =
double (*img_fvec);
989 pix[GM_idx] = m_img.colorMap (
double (*img_fvec));
993 GM_idx -= nCols * nRows - 1;
998 imvec.push_back (m_img);
1003 encode_bool_image (std::vector<Magick::Image>& imvec,
const boolNDArray& img)
1010 const Magick::Color white (
"white");
1021 Magick::Image m_img = init_enconde_image (nCols, nRows, 1,
1022 Magick::GrayscaleType,
1023 Magick::DirectClass);
1025 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1031 if (img_fvec[img_idx])
1032 pix[GM_idx] = white;
1037 GM_idx -= nCols * nRows - 1;
1040 m_img.syncPixels ();
1043 m_img.type (Magick::BilevelType);
1044 imvec.push_back (m_img);
1048 template <
typename T>
1050 encode_uint_image (std::vector<Magick::Image>& imvec,
1051 const T& img,
const T& alpha)
1053 typedef typename T::element_type
P;
1054 const octave_idx_type channels = img.ndims () < 3 ? 1 : img.dims ()(2);
1055 const octave_idx_type nFrames = img.ndims () < 4 ? 1 : img.dims ()(3);
1060 Magick::ImageType
type;
1061 const bool has_alpha = ! alpha.is_empty ();
1066 type = Magick::GrayscaleMatteType;
1068 type = Magick::GrayscaleType;
1073 type = Magick::TrueColorMatteType;
1075 type = Magick::TrueColorType;
1080 type = Magick::ColorSeparationMatteType;
1082 type = Magick::ColorSeparationType;
1087 error (
"__magick_write__: wrong size on 3rd dimension");
1097 const double divisor =
static_cast<double>((uint64_t (1) << bitdepth) - 1)
1100 const P *img_fvec = img.fortran_vec ();
1101 const P *a_fvec = alpha.fortran_vec ();
1104 case Magick::GrayscaleType:
1109 Magick::Image m_img = init_enconde_image (nCols, nRows, bitdepth,
1111 Magick::DirectClass);
1113 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1120 Magick::Color
c (grey, grey, grey);
1125 GM_idx -= nCols * nRows - 1;
1128 m_img.syncPixels ();
1129 imvec.push_back (m_img);
1134 case Magick::GrayscaleMatteType:
1139 Magick::Image m_img = init_enconde_image (nCols, nRows, bitdepth,
1141 Magick::DirectClass);
1143 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1150 Magick::Color
c (grey, grey, grey,
1157 GM_idx -= nCols * nRows - 1;
1160 m_img.syncPixels ();
1161 imvec.push_back (m_img);
1166 case Magick::TrueColorType:
1174 Magick::Image m_img = init_enconde_image (nCols, nRows, bitdepth,
1176 Magick::DirectClass);
1178 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1191 GM_idx -= nCols * nRows - 1;
1194 m_img.syncPixels ();
1195 imvec.push_back (m_img);
1196 img_fvec += B_offset;
1201 case Magick::TrueColorMatteType:
1209 Magick::Image m_img = init_enconde_image (nCols, nRows, bitdepth,
1211 Magick::DirectClass);
1213 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1228 GM_idx -= nCols * nRows - 1;
1231 m_img.syncPixels ();
1232 imvec.push_back (m_img);
1233 img_fvec += B_offset;
1238 case Magick::ColorSeparationType:
1247 Magick::Image m_img = init_enconde_image (nCols, nRows, bitdepth,
1249 Magick::DirectClass);
1251 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1265 GM_idx -= nCols * nRows - 1;
1268 m_img.syncPixels ();
1269 imvec.push_back (m_img);
1270 img_fvec += K_offset;
1275 case Magick::ColorSeparationMatteType:
1284 Magick::Image m_img = init_enconde_image (nCols, nRows, bitdepth,
1286 Magick::DirectClass);
1288 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1289 Magick::IndexPacket *ind = m_img.getIndexes ();
1305 GM_idx -= nCols * nRows - 1;
1308 m_img.syncPixels ();
1309 imvec.push_back (m_img);
1310 img_fvec += K_offset;
1316 error (
"__magick_write__: unrecognized Magick::ImageType");
1323 static std::map<octave_idx_type, std::string>
1324 init_disposal_methods ()
1341 static std::map<octave_idx_type, std::string> methods;
1342 if (methods.empty ())
1344 methods[0] =
"doNotSpecify";
1345 methods[1] =
"leaveInPlace";
1346 methods[2] =
"restoreBG";
1347 methods[3] =
"restorePrevious";
1351 static std::map<std::string, octave_idx_type>
1352 init_reverse_disposal_methods ()
1354 static std::map<std::string, octave_idx_type> methods;
1355 if (methods.empty ())
1357 methods[
"donotspecify"] = 0;
1358 methods[
"leaveinplace"] = 1;
1359 methods[
"restorebg"] = 2;
1360 methods[
"restoreprevious"] = 3;
1368 std::vector<Magick::Image>& imvec)
1372 Magick::writeImages (imvec.begin (), imvec.end (), ext +
":" +
filename);
1374 catch (Magick::Warning&
w)
1376 warning (
"Magick++ warning: %s", w.what ());
1378 catch (Magick::ErrorCoder&
e)
1380 warning (
"Magick++ coder error: %s", e.what ());
1382 catch (Magick::Exception& e)
1384 error (
"Magick++ exception: %s", e.what ());
1401 #if defined (HAVE_MAGICK)
1403 if (
args.length () != 5 || !
args(0).is_string () || !
args(1).is_string ())
1412 =
args(4).xscalar_map_value (
"__magick_write__: OPTIONS must be a struct");
1415 const Matrix cmap =
args(3).xmatrix_value (
"__magick_write__: invalid MAP");
1417 std::vector<Magick::Image> imvec;
1444 clip_img = img_float2uint<FloatNDArray>
1446 clip_alpha = img_float2uint<FloatNDArray>
1451 clip_img = img_float2uint<NDArray> (img.
array_value ());
1452 clip_alpha = img_float2uint<NDArray> (alpha.
array_value ());
1454 encode_uint_image<uint32NDArray> (imvec, clip_img, clip_alpha);
1457 error (
"__magick_write__: image type not supported");
1471 error (
"__magick_write__: indexed image must be uint8, uint16 or float.");
1473 static std::map<std::string, octave_idx_type> disposal_methods
1474 = init_reverse_disposal_methods ();
1485 imvec[
i].quality (quality);
1486 imvec[
i].animationDelay (delaytime(
i));
1487 imvec[
i].gifDisposeMethod (disposal_methods[disposalmethod(
i)]);
1495 std::vector<Magick::Image> ini_imvec;
1498 if (ini_imvec.size () > 0)
1500 ini_imvec.insert (ini_imvec.end (), imvec.begin (), imvec.end ());
1501 ini_imvec.swap (imvec);
1534 #define COMPRESS_MAGICK_IMAGE_VECTOR(GM_TYPE) \
1535 for (std::vector<Magick::Image>::size_type i = 0; i < imvec.size (); i++) \
1536 imvec[i].compressType (GM_TYPE)
1538 if (compression ==
"none")
1540 else if (compression ==
"bzip")
1542 else if (compression ==
"fax3")
1544 else if (compression ==
"fax4")
1546 else if (compression ==
"jpeg")
1548 else if (compression ==
"lzw")
1550 else if (compression ==
"rle")
1552 else if (compression ==
"deflate")
1555 #undef COMPRESS_MAGICK_IMAGE_VECTOR
1557 write_file (filename, ext, imvec);
1563 octave_unused_parameter (
args);
1589 #if defined (HAVE_MAGICK)
1591 if (
args.length () < 1 || !
args(0).is_string ())
1599 if (
args.length () > 1)
1600 idx =
args(1).int_value () -1;
1609 img.ping (filename);
1611 catch (Magick::Warning& w)
1613 warning (
"Magick++ warning: %s", w.what ());
1615 catch (Magick::Exception& e)
1617 error (
"Magick++ exception: %s", e.what ());
1620 static const char *
fields[] = {
"rows",
"columns",
"format", 0};
1630 octave_unused_parameter (
args);
1637 #if defined (HAVE_MAGICK)
1640 magick_to_octave_value (
const Magick::CompressionType& magick)
1644 case Magick::NoCompression:
1646 case Magick::BZipCompression:
1648 case Magick::FaxCompression:
1650 case Magick::Group4Compression:
1652 case Magick::JPEGCompression:
1654 case Magick::LZWCompression:
1656 case Magick::RLECompression:
1660 case Magick::ZipCompression:
1684 magick_to_octave_value (
const Magick::EndianType& magick)
1688 case Magick::LSBEndian:
1690 case Magick::MSBEndian:
1698 magick_to_octave_value (
const Magick::OrientationType& magick)
1703 case Magick::TopLeftOrientation:
1705 case Magick::TopRightOrientation:
1707 case Magick::BottomRightOrientation:
1709 case Magick::BottomLeftOrientation:
1711 case Magick::LeftTopOrientation:
1713 case Magick::RightTopOrientation:
1715 case Magick::RightBottomOrientation:
1717 case Magick::LeftBottomOrientation:
1725 magick_to_octave_value (
const Magick::ResolutionType& magick)
1729 case Magick::PixelsPerInchResolution:
1731 case Magick::PixelsPerCentimeterResolution:
1743 return (! val.empty () && val !=
"unknown");
1750 const std::string attr = img.attribute (
"EXIF:" + key);
1751 if (is_valid_exif (attr))
1760 const std::string attr = img.attribute (
"EXIF:" + key);
1761 if (is_valid_exif (attr))
1767 std::istringstream sstream (attr);
1769 while (std::getline (sstream, sub,
char (
',')))
1771 sscanf (sub.c_str (),
"%f", &
number);
1783 const std::string attr = img.attribute (
"EXIF:" + key);
1784 if (is_valid_exif (attr))
1791 std::istringstream sstream (attr);
1793 while (std::getline (sstream, sub,
','))
1795 sscanf (sub.c_str (),
"%i/%i", &numerator, &denominator);
1816 #if defined (HAVE_MAGICK)
1818 if (
args.length () < 1 || !
args(0).is_string ())
1825 std::vector<Magick::Image> imvec;
1849 static const char *fields[] =
1914 error (
"imfinfo: error reading '%s': %s", filename.c_str (),
1918 const std::string filetime = mtime.strftime (
"%e-%b-%Y %H:%M:%S");
1927 const Magick::Image img = imvec[
frame];
1929 info_frame.setfield (
"Width",
octave_value (img.columns ()));
1930 info_frame.setfield (
"Height",
octave_value (img.rows ()));
1931 info_frame.setfield (
"BitDepth",
1941 color_type =
"indexed";
1943 read_maps (const_cast<Magick::Image&> (img))(0).matrix_value ();
1947 switch (img.type ())
1949 case Magick::BilevelType:
1950 case Magick::GrayscaleType:
1951 case Magick::GrayscaleMatteType:
1952 color_type =
"grayscale";
1955 case Magick::TrueColorType:
1956 case Magick::TrueColorMatteType:
1957 color_type =
"truecolor";
1960 case Magick::PaletteType:
1961 case Magick::PaletteMatteType:
1963 color_type =
"indexed";
1966 case Magick::ColorSeparationType:
1967 case Magick::ColorSeparationMatteType:
1968 color_type =
"CMYK";
1972 color_type =
"undefined";
1975 info_frame.setfield (
"ColorType",
octave_value (color_type));
1984 double* chroma_fvec = chromaticities.fortran_vec ();
1985 img.chromaWhitePoint (&chroma_fvec[0], &chroma_fvec[1]);
1986 img.chromaRedPrimary (&chroma_fvec[2], &chroma_fvec[3]);
1987 img.chromaGreenPrimary (&chroma_fvec[4], &chroma_fvec[5]);
1988 img.chromaBluePrimary (&chroma_fvec[6], &chroma_fvec[7]);
1989 if (chromaticities.nnz () == 0)
1991 info_frame.setfield (
"Chromaticities",
octave_value (chromaticities));
1994 info_frame.setfield (
"Gamma",
octave_value (img.gamma ()));
1995 info_frame.setfield (
"XResolution",
octave_value (img.xResolution ()));
1996 info_frame.setfield (
"YResolution",
octave_value (img.yResolution ()));
1997 info_frame.setfield (
"DelayTime",
octave_value (img.animationDelay ()));
1998 info_frame.setfield (
"LoopCount",
2000 info_frame.setfield (
"Quality",
octave_value (img.quality ()));
2001 info_frame.setfield (
"Comment",
octave_value (img.comment ()));
2003 info_frame.setfield (
"Compression",
2004 magick_to_octave_value (img.compressType ()));
2005 info_frame.setfield (
"Orientation",
2006 magick_to_octave_value (img.orientation ()));
2007 info_frame.setfield (
"ResolutionUnit",
2008 magick_to_octave_value (img.resolutionUnits ()));
2009 info_frame.setfield (
"ByteOrder",
2010 magick_to_octave_value (img.endian ()));
2016 Magick::Image& cimg =
const_cast<Magick::Image&
> (img);
2025 static const char *base_exif_str_fields[] =
2036 static const string_vector base_exif_str (base_exif_str_fields);
2037 static const octave_idx_type n_base_exif_str = base_exif_str.numel ();
2040 info_frame.setfield (base_exif_str[field],
2042 fill_exif (info_frame, cimg, base_exif_str[field]);
2047 if (! cimg.attribute (
"EXIF:ExifVersion").empty ())
2053 static const char *exif_str_fields[] =
2057 "DateTimeDigitized",
2060 "SubSecTimeOriginal",
2061 "SubSecTimeDigitized",
2068 "SpectralSensitivity",
2078 fill_exif (camera, cimg, exif_str[field]);
2081 static const char *exif_int_fields[] =
2086 "PhotographicSensitivity",
2087 "StandardOutputSensitivity",
2088 "RecommendedExposureIndex",
2090 "ISOSpeedLatitudeyyy",
2091 "ISOSpeedLatitudezzz",
2092 "FocalPlaneResolutionUnit",
2093 "FocalLengthIn35mmFilm",
2116 "SubjectDistanceRange",
2122 fill_exif_ints (camera, cimg, exif_int[field]);
2125 static const char *exif_float_fields[] =
2128 "CompressedBitsPerPixel",
2131 "ShutterSpeedValue",
2134 "ExposureBiasValue",
2139 "FocalPlaneXResolution",
2140 "FocalPlaneYResolution",
2144 "LensSpecification",
2150 fill_exif_floats (camera, cimg, exif_float[field]);
2155 if (cimg.attribute (
"EXIF:GPSInfo") !=
"unknown")
2161 static const char *gps_str_fields[] =
2171 "GPSImgDirectionRef",
2173 "GPSDestLatitudeRef",
2174 "GPSDestLongitudeRef",
2175 "GPSDestBearingRef",
2176 "GPSDestDistanceRef",
2183 fill_exif (gps, cimg, gps_str[field]);
2185 static const char *gps_int_fields[] =
2193 fill_exif_ints (gps, cimg, gps_int[field]);
2195 static const char *gps_float_fields[] =
2204 "GPSHPositioningError",
2216 fill_exif_floats (gps, cimg, gps_float[field]);
2220 info_frame.setfield (
"DigitalCamera",
octave_value (camera));
2224 info.fast_elem_insert (
frame, info_frame);
2227 if (format ==
"GIF")
2229 static std::map<octave_idx_type, std::string> disposal_methods
2230 = init_disposal_methods ();
2233 methods[
frame] = disposal_methods[imvec[
frame].gifDisposeMethod ()];
2234 info.setfield (
"DisposalMethod",
Cell (methods));
2237 info.setfield (
"DisposalMethod",
2244 octave_unused_parameter (
args);
2264 if (
args.length () != 1 || !
args(0).is_map ())
2269 #if defined (HAVE_MAGICK)
2281 fmt.
setfield (
"multipage", coder.isMultiFrame () ?
true :
false);
2284 if (! coder.isReadable ())
2286 if (! coder.isWritable ())
2290 catch (Magick::Exception& e)
2305 return ovl (formats);
uint8NDArray uint8_array_value(void) const
void warning_with_id(const char *id, const char *fmt,...)
ColumnVector column_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
bool is_empty(void) const
scalar structure containing the fields
bool is_range(void) const
OCTAVE_EXPORT octave_value_list column
octave::sys::time mtime(void) const
void delete_elements(const idx_vector &i)
#define COMPRESS_MAGICK_IMAGE_VECTOR(GM_TYPE)
unsigned int uint_value(bool req_int=false, bool frc_str_conv=false) const
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_integer_type())
bool is_uint16_type(void) const
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
static Range get_region_range(const octave_value ®ion)
identity matrix If supplied two scalar respectively For allows like xample val
static bool is_indexed(const Magick::Image &img)
bool is_scalar_type(void) const
int int_value(bool req_int=false, bool frc_str_conv=false) const
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
static void read_file(const std::string &filename, std::vector< Magick::Image > &imvec)
void setfield(const std::string &key, const octave_value &val)
static void maybe_initialize_magick(void)
octave_idx_type numel(void) const
double scalar_value(bool frc_str_conv=false) const
boolNDArray bool_array_value(bool warn=false) const
octave_idx_type rows(void) const
cell array If invoked with two or more scalar integer or a vector of integer values
static octave_value_list read_indexed_images(const std::vector< Magick::Image > &imvec, const Array< octave_idx_type > &frameidx, const octave_idx_type &nargout, const octave_scalar_map &options)
Cell cell_value(void) const
bool is_float_type(void) const
Array< std::string > cellstr_value(void) const
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
FloatNDArray float_array_value(bool frc_str_conv=false) const
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
bool is_bool_type(void) const
std::string string_value(bool force=false) const
Range range_value(void) const
std::complex< double > w(std::complex< double > z, double relerr=0)
bool is_string(void) const
octave_idx_type numel(void) const
Array< int > xint_vector_value(const char *fmt,...) const
bool fast_elem_insert(octave_idx_type n, const octave_scalar_map &rhs)
void resize(const dim_vector &dv, const T &rfv)
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
static octave_int< T > max(void)
static octave_value_list read_maps(Magick::Image &img)
octave_value_list read_images(std::vector< Magick::Image > &imvec, const Array< octave_idx_type > &frameidx, const octave_idx_type &nargout, const octave_scalar_map &options)
void warning(const char *fmt,...)
octave::unwind_protect frame
charNDArray max(char d, const charNDArray &m)
T::size_type numel(const T &str)
NDArray array_value(bool frc_str_conv=false) const
static std::map< std::string, octave_idx_type > calculate_region(const octave_scalar_map &options)
static octave_idx_type get_depth(Magick::Image &img)
=val(i)}if ode{val(i)}occurs in table i
bool is_uint8_type(void) const
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol zero divided by nd tex zero divided by nd ifnottex and any operation involving another NaN value(5+NaN).Note that NaN always compares not equal to NaN(NaN!
issues an error eealso double
OCTAVE_EXPORT octave_value_list only variables visible in the local scope are displayed The following are valid options
octave::sys::file_stat fs(filename)
octave_scalar_map checkelem(octave_idx_type n) const
octave_value getfield(const std::string &key) const
static std::string get_program_invocation_name(void)
std::string error(void) const
const T * fortran_vec(void) const
bool is_single_type(void) const
bool is_uint32_type(void) const
Vector representing the dimensions (size) of an Array.
uint32NDArray uint32_array_value(void) const
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
string_vector fieldnames(void) const
uint16NDArray uint16_array_value(void) const
octave_idx_type columns(void) const
where the brackets indicate optional arguments and and character or cell array For character arrays the conversion is repeated for every row
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))