Skip to content
Snippets Groups Projects
Commit df7245a8 authored by Provot Bertrand's avatar Provot Bertrand
Browse files

Merge remote-tracking branch 'origin/dev2018' into dev2018

parents 87bb4e41 35942a12
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ void DoubleEntropyOp::operator()(const Image_t<double>* image, const std::map<co
double entropy = image->getEntropy();
outText(qApp->translate("Operations", "Entropy of the image (sum of channels entropy) = %1\n").arg(entropy).toStdString());
outText(qApp->translate("Pas d'échantillonnage choisi : 1\n"));
outText(qApp->translate("Operations", "Pas d'échantillonnage choisi : 1\n").toStdString());
}
bool DoubleEntropyOp::needCurrentImg() const {
......
......@@ -46,11 +46,11 @@ struct Point {
Point(int x_=0, int y_=0) : x(x_), y(y_) {}
};
inline Point rotatePoint(Point toRotate, double sin, double cos)
inline Point rotatePoint(Point toRotate, Point rotatePoint, double sin, double cos)
{
Point returnval;
returnval.x = ((double)toRotate.x) * cos + ((double)toRotate.y) * sin;
returnval.y = ((double)toRotate.y) * cos - ((double)toRotate.x) * sin;
returnval.x = ((double) (toRotate.x - rotatePoint.x)) * cos + ((double) (toRotate.y - rotatePoint.y)) * sin + rotatePoint.x;
returnval.y = ((double) (toRotate.y - rotatePoint.y)) * cos - ((double) (toRotate.x - rotatePoint.x))* sin + rotatePoint.y;
return returnval;
}
......@@ -112,13 +112,13 @@ void RotateOp::operator()(const Image* img, const map<const Image*, string>& img
// Calculate the size of the new bitmap
Point rotation_point;
rotation_point.x = 0;
rotation_point.y = 0;
rotation_point.x = img->getWidth()/2;
rotation_point.y = img->getHeight()/2;
Point p1 = rotatePoint(Point(0,0), sin_angle, cos_angle);
Point p2 = rotatePoint(Point(img->getWidth()-1,0), sin_angle, cos_angle);
Point p3 = rotatePoint(Point(0,img->getHeight()-1), sin_angle, cos_angle);
Point p4 = rotatePoint(Point(img->getWidth()-1,img->getHeight()-1), sin_angle, cos_angle);
Point p1 = rotatePoint(Point(0,0), rotation_point, sin_angle, cos_angle);
Point p2 = rotatePoint(Point(img->getWidth()-1,0), rotation_point, sin_angle, cos_angle);
Point p3 = rotatePoint(Point(0,img->getHeight()-1), rotation_point, sin_angle, cos_angle);
Point p4 = rotatePoint(Point(img->getWidth()-1,img->getHeight()-1), rotation_point, sin_angle, cos_angle);
int min_x = min(min(p1.x,p2.x),min(p3.x,p4.x));
int max_x = max(max(p1.x,p2.x),max(p3.x,p4.x));
......@@ -133,23 +133,15 @@ void RotateOp::operator()(const Image* img, const map<const Image*, string>& img
Image *resImg = new Image(nWidth, nHeight, img->getNbChannels(), fillValue);
Point source_point;
for(unsigned int c = 0; c < resImg->getNbChannels(); ++c) {
for(unsigned int hcounter=0;hcounter<nHeight;hcounter++) {
for(unsigned int wcounter=0;wcounter<nWidth;wcounter++) {
source_point.x = wcounter + min_x;
source_point.y = hcounter + min_y;
source_point = rotatePoint(source_point,sin_neg_ang,cos_neg_ang);
source_point.x = source_point.x + rotation_point.x;
source_point.y = source_point.y + rotation_point.y;
if( (source_point.x>=0)
&&(source_point.x<Width)
&&(source_point.y>=0)
&&(source_point.y<Height)) {
resImg->setPixel(wcounter,hcounter,c, img->getPixel(source_point.x,source_point.y, c));
for(unsigned int c = 0; c < resImg->getNbChannels(); ++c){
for(unsigned int i = 0; i<resImg->getWidth(); i++){
for(unsigned int j = 0; j<resImg->getHeight(); j++){
source_point = rotatePoint(Point(i,j), rotation_point, sin_neg_ang, cos_neg_ang );
try {
resImg->setPixel(i,j, c,img->getPixel(source_point.x,source_point.y,c));
}
catch(std::out_of_range){}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment