Code: Select all
#include <Magick++.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
//g++ `Magick++-config --cxxflags --cppflags` -o -imageTest imageTest.cpp `Magick++-config --ldflags --libs`
using namespace std;
using namespace Magick;
int main(int argc, char *argv[])
{
Image my_image; // create an *empty* image using the default Image constructor
my_image.read("out.jpg");
//make safe changes to image
my_image.modifyImage();
Pixels view(my_image);
//final destination for region. Cover (0, 160) to (640, 320)
int columns = 640; int rows = 320;
PixelPacket *pixel_cache = view.get(0,160,columns, rows);
for(int row = 160; row < rows; row++)
for(int col = 0;col < columns; col++)
{
//search for blue pixels
//R:65 G:118 B:188
*pixel_cache++;
//printf(colr);
Color cnvrt = *pixel_cache;//THIS IS THE LINE WHICH CAUSES ISSUES
Quantum b = cnvrt.blueQuantum();
Quantum r = cnvrt.redQuantum();
if(b > 26000)
if(r < 30000)
{
*pixel_cache = green;
}
}
view.sync();
my_image.write("outMOD.jpg");
}