예제 #1
0
void performHighPass(const cv::Mat& image, cv::Mat& res, int rad) {
    cv::Mat grey, tmp;
    cv::cvtColor(image, grey, CV_BGR2GRAY);


    grey.convertTo(grey, CV_32F);
    grey.copyTo(res);
    res.convertTo(res, CV_8U);
    std::vector<cv::Mat> planes(2, cv::Mat());
    std::vector<cv::Mat> polar(2, cv::Mat());

    cv::dft(grey, tmp, cv::DFT_COMPLEX_OUTPUT);
    cv::split(tmp, planes);
    cv::cartToPolar(planes[0], planes[1], polar[0], polar[1]);
    visualization(polar[0], tmp);
    concatImages(res, tmp, res);

    rearrangeQuadrants(polar[0]);
    highPassFilter(polar[0], rad);
    rearrangeQuadrants(polar[0]);

    visualization(polar[0], tmp);
    tmp.convertTo(tmp, res.type());
    concatImages(res, tmp, res);

    cv::polarToCart(polar[0], polar[1], planes[0], planes[1]);
    cv::merge(planes, tmp);
    cv::dft(tmp, tmp, cv::DFT_SCALE | cv::DFT_INVERSE | cv::DFT_REAL_OUTPUT);
    tmp.convertTo(tmp, CV_8U);
    concatImages(res, tmp, res);
}
예제 #2
0
 bool cull(const AABB& aabb) const
 {
   if (aabb.isNull())
     return false;
   for(unsigned i=0; i<planes().size(); ++i)
   {
     if ( plane(i).isOutside(aabb) )
       return true;
   }
   return false;
 }
예제 #3
0
 bool cull(const Sphere& sphere) const
 {
   // null spheres are always visible
   if (sphere.isNull())
     return false;
   for(unsigned i=0; i<planes().size(); ++i)
   {
     if ( plane(i).distance(sphere.center()) > sphere.radius() )
       return true;
   }
   return false;
 }
예제 #4
0
 bool cull(const std::vector<fvec3>& points) const
 {
   for(unsigned i=0; i<planes().size(); ++i)
   {
     unsigned j=0;
     for(; j<points.size(); ++j)
       if ( plane(i).distance((vec3)points[j]) <= 0 )
         break;
     if(j == points.size())
       return true;
   }
   return false;
 }
예제 #5
0
void addShaderDefines(Shader& shader, const VolumeIndicatorProperty& property) {
    // compositing defines
    std::string key = "DRAW_PLANES(result, samplePosition, rayDirection, increment, params)";
    std::string value = "result";

    if (property.enable_ &&
        (property.plane1_.enable_ || property.plane2_.enable_ || property.plane3_.enable_)) {
        std::string planes("");
        planes += property.plane1_.enable_ ? ", params.plane1" : ""; 
        planes += property.plane2_.enable_ ? ", params.plane2" : ""; 
        planes += property.plane3_.enable_ ? ", params.plane3" : "";
        value = "drawPlanes(result, samplePosition, rayDirection, increment " + planes + ")";
    }
    shader.getFragmentShaderObject()->addShaderDefine(key, value);
}
예제 #6
0
bool CObjTreePlugin::srvInsertPlanes(srs_env_model::InsertPlanes::Request &req, srs_env_model::InsertPlanes::Response &res)
{
    std::vector<srs_env_model_msgs::PlaneDesc>::iterator i;
    std::vector<srs_env_model_msgs::PlaneDesc> &planes(req.plane_array.planes);

    for(i = planes.begin(); i != planes.end(); i++)
    {
        unsigned int id = insertPlane(*i, INSERT);
        res.object_ids.push_back(id);

        showObject(id);
    }

    return true;
}
/**
 * @brief Insert or modify plane array
 *
 * @param pa Array of planes
 */
bool srs_env_model::CIMarkersPlugin::insertPlaneCallback(srs_env_model::AddPlanes::Request & req,
	srs_env_model::AddPlanes::Response & res) {
	std::cerr << "Inset plane called" << std::endl;
	// Get plane array
	srs_env_model_msgs::PlaneArray & planea(req.plane_array);
	m_planesFrameId = planea.header.frame_id;
	std::vector<srs_env_model_msgs::PlaneDesc> & planes(planea.planes);
	std::vector<srs_env_model_msgs::PlaneDesc>::iterator i;

	for (i = planes.begin(); i != planes.end(); ++i) {
		operatePlane(*i);
	}

	return true;
}
예제 #8
0
void csBSPTree::Build (CS::TriangleIndicesStream<int>& triangles,
	               const csVector3* vertices)
{
  const size_t triComponents = triangles.GetRemainingComponents();
  csDirtyAccessArray<csPlane3> planes ((triComponents+2)/3);
  csArray<int> triidx;
  csDirtyAccessArray<csTriangle> tris ((triComponents+2)/3);
  while (triangles.HasNext())
  {
    CS::TriangleT<int> t (triangles.Next());
    planes.Push (csPlane3 (vertices[t.a], vertices[t.b], vertices[t.c]));
    triidx.Push (int (tris.Push (t)));
  }

  Build (tris.GetArray(), planes.GetArray(), tris.GetSize(), vertices, triidx);
}
예제 #9
0
static void ConvertWorldBrushesToPhysCollide( CUtlVector<CPhysCollisionEntry *> &collisionList, float shrinkSize, float mergeTolerance, int contentsMask )
{
	CPlaneList planes( shrinkSize, mergeTolerance );

	planes.m_contentsMask = contentsMask;

	VisitLeaves_r( planes, dmodels[0].headnode );
	planes.AddBrushes();
	
	int count = planes.m_convex.Count();
	if ( count )
	{
		CPhysCollide *pCollide = physcollision->ConvertConvexToCollide( planes.m_convex.Base(), count );

		ICollisionQuery *pQuery = physcollision->CreateQueryModel( pCollide );
		int convex = pQuery->ConvexCount();
		for ( int i = 0; i < convex; i++ )
		{
			int triCount = pQuery->TriangleCount( i );
			int brushIndex = pQuery->GetGameData( i );

			Vector points[3];
			for ( int j = 0; j < triCount; j++ )
			{
				pQuery->GetTriangleVerts( i, j, points );
				Vector normal = TriangleNormal( points[0], points[1], points[2] );
				dbrushside_t *pside = FindBrushSide( brushIndex, normal );
				if ( pside->texinfo != TEXINFO_NODE )
				{
					int prop = g_SurfaceProperties[texinfo[pside->texinfo].texdata];
					pQuery->SetTriangleMaterialIndex( i, j, RemapWorldMaterial( prop ) );
				}
			}
		}
		physcollision->DestroyQueryModel( pQuery );
		pQuery = NULL;

		collisionList.AddToTail( new CPhysCollisionEntryStaticSolid( pCollide, contentsMask ) );
	}
}
Polyhedron_3 obtainPolyhedron(Polyhedron_3 initialP, std::map<int, int> map,
		IpoptTopologicalCorrector *FTNLP)
{
	DEBUG_START;
	std::vector<Vector_3> directions = FTNLP->getDirections();
	std::vector<double> values = FTNLP->getValues();
	std::vector<Plane_3> planes(initialP.size_of_facets());
	unsigned iFacet = 0;
	for (auto I = initialP.facets_begin(), E = initialP.facets_end();
			I != E; ++I)
	{
		auto it = map.find(iFacet);
		if (it != map.end())
		{
			int i = it->second;
			Vector_3 u = directions[i];
			double h = values[i];
			ASSERT(h > 0);
			planes[iFacet] = Plane_3(-u.x(), -u.y(), -u.z(), h);
			std::cout << "Changing plane #" << iFacet << ": "
				<< I->plane() << " |--> " << planes[iFacet]
				<< std::endl;
		}
		else
		{
			planes[iFacet] = I->plane();
		}
		++iFacet;
	}

	Polyhedron_3 intersection(planes);
	std::cout << "Change in facets number: " << initialP.size_of_facets()
		<< " -> " << intersection.size_of_facets() << std::endl;
	ASSERT(initialP.size_of_facets() - intersection.size_of_facets()
			< map.size() &&
			"It seems that all extracted facets have gone");
	DEBUG_END;
	return intersection;
}
예제 #11
0
void DRGeometrieSphere::makeSphericalLandscape(GLuint numIterations, GLuint randomSeed)
{
    if(!mVertexCount) LOG_ERROR_VOID("keine Vertices zum manipulieren!");
    DRRandom::seed(randomSeed);
    
    const int threadCount = g_CPU_Count;   
    PlaneData planes(numIterations, randomSeed);
    LandscapeGenerateMultithreadData* workingData = new LandscapeGenerateMultithreadData[threadCount];
    SDL_Thread** threads = new SDL_Thread*[threadCount];
    
    for(int i = 0; i < threadCount; i++)
    {
        workingData[i].planes = &planes;
        workingData[i].vertices = &mVertices[mVertexCount/threadCount*i];
        workingData[i].vertexCount = mVertexCount/threadCount;
#if SDL_VERSION_ATLEAST(1,3,0)
        threads[i] = SDL_CreateThread(makeLandscapeThread, "DRGeoLSC" ,&workingData[i]);
#else
        threads[i] = SDL_CreateThread(makeLandscapeThread, &workingData[i]);
#endif
        printf("thread: %d, vertexIndex: %ld, vertexCount: %ld, ges vertexCount: %ld\n",i, mVertexCount/threadCount*i, mVertexCount/threadCount, mVertexCount);
    }
    
    for(int i = 0; i < threadCount; i++)
    {
        int returnValue = 0;
        SDL_WaitThread(threads[i], &returnValue);
        if(returnValue)
        {
            LOG_WARNING("Fehler in Thread occured");
            DRLog.writeToLog("Thread %d return with error: %d", i, returnValue);            
        }
    }    
    DR_SAVE_DELETE_ARRAY(threads);
    DR_SAVE_DELETE_ARRAY(workingData);
}
예제 #12
0
bool Cone::InitAverage(const MiscLib::Vector< Vec3f > &samples)
{
	// setup all the planes
	size_t c = samples.size() / 2;
	MiscLib::Vector< GfxTL::Vector4Df > planes(c);
	#pragma omp parallel for schedule(static)
	for(size_t i = 0; i < c; ++i)
	{
		for(unsigned int j = 0; j < 3; ++j)
			planes[i][j] = samples[i][j];
		planes[i][3] = samples[i].dot(samples[i + c]);
	}
	// compute center by intersecting the three planes given by (p1, n1)
	// (p2, n2) and (p3, n3)
	// set up linear system
	double a[4 * 3];
	double d1 = samples[0].dot(samples[c + 0]);
	double d2 = samples[1].dot(samples[c + 1]);
	double d3 = samples[2].dot(samples[c + 2]);
	// column major
	a[0 + 0 * 3] = samples[c + 0][0];
	a[1 + 0 * 3] = samples[c + 1][0];
	a[2 + 0 * 3] = samples[c + 2][0];
	a[0 + 1 * 3] = samples[c + 0][1];
	a[1 + 1 * 3] = samples[c + 1][1];
	a[2 + 1 * 3] = samples[c + 2][1];
	a[0 + 2 * 3] = samples[c + 0][2];
	a[1 + 2 * 3] = samples[c + 1][2];
	a[2 + 2 * 3] = samples[c + 2][2];
	a[0 + 3 * 3] = d1;
	a[1 + 3 * 3] = d2;
	a[2 + 3 * 3] = d3;
	if(dmat_solve(3, 1, a))
		return false;
	m_center[0] = a[0 + 3 * 3];
	m_center[1] = a[1 + 3 * 3];
	m_center[2] = a[2 + 3 * 3];

	LevMarPlaneDistance planeDistance;
	LevMar(planes.begin(), planes.end(), planeDistance,
		(float *)m_center);

	MiscLib::Vector< GfxTL::Vector3Df > spoints(c);
	#pragma omp parallel for schedule(static)
	for(size_t i = 0; i < c; ++i)
	{
		spoints[i] = GfxTL::Vector3Df(samples[i] - m_center);
		spoints[i].Normalize();
	}
	GfxTL::Vector3Df axisDir;
	GfxTL::MeanOfNormals(spoints.begin(), spoints.end(), &axisDir);
	m_axisDir = GfxTL::Vector3Df(axisDir);

	// make sure axis points in good direction
	// the axis is defined to point into the interior of the cone
	float heightSum = 0;
	#pragma omp parallel for schedule(static) reduction(+:heightSum)
	for(size_t i = 0; i < c; ++i)
		heightSum += Height(samples[i]);
	if(heightSum < 0)
		m_axisDir *= -1;

	float angleReduction = 0;
	#pragma omp parallel for schedule(static) reduction(+:angleReduction)
	for(size_t i = 0; i < c; ++i)
	{
		float angle = m_axisDir.dot(samples[i + c]);
		if(angle < -1) // clamp angle to [-1, 1]
			angle = -1;
		else if(angle > 1)
			angle = 1;
		if(angle < 0)
			// m_angle = omega + 90
			angle = std::acos(angle) - float(M_PI) / 2;
		else
			// m_angle = 90 - omega
			angle = float(M_PI) / 2 - std::acos(angle);
		angleReduction += angle;
	}
	angleReduction /= c;
	m_angle = angleReduction;
	if(m_angle < 1.0e-6 || m_angle > float(M_PI) / 2 - 1.0e-6)
		return false;
	//if(m_angle > 1.3962634015954636615389526147909) // 80 degrees
	if(m_angle > 1.4835298641951801403851371532153f) // 85 degrees
		return false;
	m_normal = Vec3f(std::cos(-m_angle), std::sin(-m_angle), 0);
	m_normalY = m_normal[1] * m_axisDir;
	m_n2d[0] = std::cos(m_angle);
	m_n2d[1] = -std::sin(m_angle);
	m_hcs.FromNormal(m_axisDir);
	m_angularRotatedRadians = 0;
	return true;
}
예제 #13
0
// adds a collision entry for this brush model
static void ConvertModelToPhysCollide( CUtlVector<CPhysCollisionEntry *> &collisionList, int modelIndex, int contents, float shrinkSize, float mergeTolerance )
{
	int i;
	CPlaneList planes( shrinkSize, mergeTolerance );

	planes.m_contentsMask = contents;

	dmodel_t *pModel = dmodels + modelIndex;
	VisitLeaves_r( planes, pModel->headnode );
	planes.AddBrushes();
	int count = planes.m_convex.Count();
	convertconvexparams_t params;
	params.Defaults();
	params.buildOuterConvexHull = count > 1 ? true : false;
	params.buildDragAxisAreas = true;
	Vector size = pModel->maxs - pModel->mins;

	float minSurfaceArea = -1.0f;
	for ( i = 0; i < 3; i++ )
	{
		int other = (i+1)%3;
		int cross = (i+2)%3;
		float surfaceArea = size[other] * size[cross];
		if ( minSurfaceArea < 0 || surfaceArea < minSurfaceArea )
		{
			minSurfaceArea = surfaceArea;
		}
	}
	// this can be really slow with super-large models and a low error tolerance
	// Basically you get a ray cast through each square of epsilon surface area on each OBB side
	// So compute it for 1% error (on the smallest side, less on larger sides)
	params.dragAreaEpsilon = clamp( minSurfaceArea * 1e-2f, 1.0f, 1024.0f );
	CPhysCollide *pCollide = physcollision->ConvertConvexToCollideParams( planes.m_convex.Base(), count, params );
	
	if ( !pCollide )
		return;

	struct 
	{
		int prop;
		float area;
	} proplist[256];
	int numprops = 1;

	proplist[0].prop = -1;
	proplist[0].area = 1;
	// compute the array of props on the surface of this model

	// NODRAW brushes no longer have any faces
	if ( !dmodels[modelIndex].numfaces )
	{
		int sideIndex = planes.GetFirstBrushSide();
		int texdata = texinfo[dbrushsides[sideIndex].texinfo].texdata;
		int prop = g_SurfaceProperties[texdata];
		proplist[numprops].prop = prop;
		proplist[numprops].area = 2;
		numprops++;
	}

	for ( i = 0; i < dmodels[modelIndex].numfaces; i++ )
	{
		dface_t *face = dfaces + i + dmodels[modelIndex].firstface;
		int texdata = texinfo[face->texinfo].texdata;
		int prop = g_SurfaceProperties[texdata];
		int j;
		for ( j = 0; j < numprops; j++ )
		{
			if ( proplist[j].prop == prop )
			{
				proplist[j].area += face->area;
				break;
			}
		}

		if ( (!numprops || j >= numprops) && numprops < ARRAYSIZE(proplist) )
		{
			proplist[numprops].prop = prop;
			proplist[numprops].area = face->area;
			numprops++;
		}
	}


	// choose the prop with the most surface area
	int maxIndex = -1;
	float maxArea = 0;
	float totalArea = 0;

	for ( i = 0; i < numprops; i++ )
	{
		if ( proplist[i].area > maxArea )
		{
			maxIndex = i;
			maxArea = proplist[i].area;
		}
		// add up the total surface area
		totalArea += proplist[i].area;
	}
	
	float mass = 1.0f;
	const char *pMaterial = "default";
	if ( maxIndex >= 0 )
	{
		int prop = proplist[maxIndex].prop;
		
		// use default if this material has no prop
		if ( prop < 0 )
			prop = 0;

		pMaterial = physprops->GetPropName( prop );
		float density, thickness;
		physprops->GetPhysicsProperties( prop, &density, &thickness, NULL, NULL );

		// if this is a "shell" material (it is hollow and encloses some empty space)
		// compute the mass with a constant surface thickness
		if ( thickness != 0 )
		{
			mass = totalArea * thickness * density * CUBIC_METERS_PER_CUBIC_INCH;
		}
		else
		{
			// material is completely solid, compute total mass as if constant density throughout.
			mass = planes.m_totalVolume * density * CUBIC_METERS_PER_CUBIC_INCH;
		}
	}

	// Clamp mass to 100,000 kg
	if ( mass > VPHYSICS_MAX_MASS )
	{
		mass = VPHYSICS_MAX_MASS;
	}

	collisionList.AddToTail( new CPhysCollisionEntrySolid( pCollide, pMaterial, mass ) );
}
예제 #14
0
static void ConvertWaterModelToPhysCollide( CUtlVector<CPhysCollisionEntry *> &collisionList, int modelIndex, 
										    float shrinkSize, float mergeTolerance )
{
	dmodel_t *pModel = dmodels + modelIndex;

	for ( int i = 0; i < g_WaterModels.Count(); i++ )
	{
		watermodel_t &waterModel = g_WaterModels[i];
		if ( waterModel.modelIndex != modelIndex )
			continue;

		CPlaneList planes( shrinkSize, mergeTolerance );
		int firstLeaf = waterModel.firstWaterLeafIndex;
		planes.m_contentsMask = waterModel.contents;
		
		// push all of the leaves into the collision list
		for ( int j = 0; j < waterModel.waterLeafCount; j++ )
		{
			int leafIndex = g_WaterLeafList[firstLeaf + j];

			dleaf_t *pLeaf = dleafs + leafIndex;
			// fixup waterdata
			pLeaf->leafWaterDataID = waterModel.fogVolumeIndex;
			planes.ReferenceLeaf( leafIndex );
		}
	
		// visit the referenced leaves that belong to this model
		VisitLeaves_r( planes, pModel->headnode );

		// Now add the brushes from those leaves as convex

		// BUGBUG: NOTE: If your map has a brush that crosses the surface, it will be added to two water
		// volumes.  This only happens with connected water volumes with multiple surface heights
		// UNDONE: Right now map makers must cut such brushes.  It could be automatically cut by adding the
		// surface plane to the list for each brush before calling ConvexFromPlanes()
		planes.AddBrushes();

		int count = planes.m_convex.Count();
		if ( !count )
			continue;

		// Save off the plane of the surface for this group as well as the collision model
		// for all convex objects in the group.
		CPhysCollide *pCollide = physcollision->ConvertConvexToCollide( planes.m_convex.Base(), count );
		if ( pCollide )
		{
			int waterSurfaceTexInfoID = -1;
			// use defaults
			const char *pSurfaceProp = "water";
			float damping = 0.01;
			if ( waterSurfaceTexInfoID >= 0 )
			{
				// material override
				int texdata = texinfo[waterSurfaceTexInfoID].texdata;
				int prop = g_SurfaceProperties[texdata];
				pSurfaceProp = physprops->GetPropName( prop );
			}

			if ( !waterModel.waterLeafData.hasSurface )
			{
				waterModel.waterLeafData.surfaceNormal.Init( 0,0,1 );
				Vector top = physcollision->CollideGetExtent( pCollide, vec3_origin, vec3_angle, waterModel.waterLeafData.surfaceNormal );
				waterModel.waterLeafData.surfaceDist = top.z;
			}
			CPhysCollisionEntryFluid *pCollisionEntryFuild = new CPhysCollisionEntryFluid( pCollide, 
				pSurfaceProp, damping, waterModel.waterLeafData.surfaceNormal, waterModel.waterLeafData.surfaceDist, waterModel.contents );
			collisionList.AddToTail( pCollisionEntryFuild );
		}
	}
}
예제 #15
0
bool task3_5(const cv::Mat& image, const cv::Mat& orig) {
    cv::Mat grey, tmp, res;
    image.copyTo(grey);
    grey.convertTo(grey, CV_32F);

    grey.copyTo(res);
    res.convertTo(res, CV_8U);
    std::vector<cv::Mat> planes(2, cv::Mat());
    std::vector<cv::Mat> polar(2, cv::Mat());

    cv::dft(grey, tmp, cv::DFT_COMPLEX_OUTPUT);
    cv::split(tmp, planes);
    cv::cartToPolar(planes[0], planes[1], polar[0], polar[1]);

    int cx = polar[0].cols / 2;
    int cy = polar[0].rows / 2;
    cv::Point max;

    cv::Mat top = polar[0].rowRange(0, cx);
    cv::Mat bot = polar[0].rowRange(cx, polar[0].rows);

    int row = 0;
    do {
        cv::minMaxLoc(top.rowRange(row++, top.rows), 0, 0, 0, &max);
    } while (max.x == 0);


    int r = 3;

    cv::Mat noizeCol = polar[0].colRange(max.x - r, max.x + r);
    cv::Mat noizeRow = polar[0].rowRange(max.y - r, max.y + r);
    cv::Mat blurCol = polar[0].colRange(max.x - 12, max.x - 12 + 2 * r);
    cv::Mat blurRow = polar[0].rowRange(max.y - 3 * r, max.y - r);

    blurCol.copyTo(noizeCol);
    blurRow.copyTo(noizeRow);


    cv::Mat noizeColB = polar[0].colRange(polar[0].cols - max.x - r, polar[0].cols - max.x + r);
    cv::Mat noizeRowB = polar[0].rowRange(polar[0].rows - max.y - r, polar[0].rows - max.y + r);

    blurCol.copyTo(noizeColB);
    blurRow.copyTo(noizeRowB);

    cv::Mat roi = polar[0];
    cv::Mat mean, stddev, tmp1;
    roi = roi.colRange(max.x + 20, roi.cols - max.x - 20).rowRange(max.y + 20, roi.cols - max.y - 20);
    for (int i = 0; i < roi.rows; ++i) {
        cv::Mat row = roi.row(i);
        cv::meanStdDev(row, mean, stddev);
        float m = mean.at<double>(0, 0);
        float st = stddev.at<double>(0, 0);
        for (Mfit mfit = row.begin<float>(); mfit != row.end<float>(); ++mfit) {
            if (*mfit > m + 1.5 * st) {
                *mfit = 0.5 * m;
            }
        }
    }
    visualization(polar[0], tmp);

    //    
    //    
    //    cv::namedWindow("Lesson 2", CV_WINDOW_NORMAL);
    //    cv::imshow("Lesson 2", tmp);
    //    cv::waitKey(0);


    cv::polarToCart(polar[0], polar[1], planes[0], planes[1]);
    cv::merge(planes, tmp);
    cv::dft(tmp, tmp, cv::DFT_SCALE | cv::DFT_INVERSE | cv::DFT_REAL_OUTPUT);



    tmp.convertTo(tmp, CV_8U);



    cv::Mat lut(1, 256, CV_32F, cv::Scalar(0));
    for (int i = 0; i < 256; ++i) {
        lut.at<float>(0, i) = i;
    }

    for (int i = 65; i < 200; ++i) {
        lut.at<float>(0, i) = i - 30;
    }
    
    for (int i = 200; i < 220; ++i) {
        lut.at<float>(0, i) = i - 20;
    }
    
    lut.convertTo(lut, CV_8U);

    tmp.convertTo(tmp, CV_8U);

    cv::normalize(tmp, tmp, 0, 255, cv::NORM_MINMAX);
    
    cv::LUT(tmp, lut, tmp);


    cv::GaussianBlur(tmp, tmp, cv::Size(3, 3), 1);
    cv::medianBlur(tmp, tmp, 3);
    cv::Mat result;
    cv::matchTemplate(orig, tmp, result, CV_TM_SQDIFF);
    std::cout << "RMSE Task 3.5: " << result / (orig.cols * orig.rows) << std::endl;

    concatImages(res, tmp, res);
    cv::absdiff(tmp, orig, tmp);
    concatImages(res, tmp, res);

    cv::absdiff(image, orig, tmp);
    concatImages(res, tmp, res);
    concatImages(res, orig, res);

//    cv::namedWindow("Lesson 2", CV_WINDOW_NORMAL);
//    cv::imshow("Lesson 2", res);
//    cv::waitKey(0);

    return cv::imwrite(PATH + "Task3_5.jpg", res);
}
예제 #16
0
void MainWindow::load()
{
    QString fileName =
            QFileDialog::getOpenFileName(this, tr("Open KD Chart 2 File"),
                                         QDir::currentPath(),
                                         tr("KDC2 Files (*.kdc2 *.xml)"));
    if (fileName.isEmpty())
        return;

    QFile file(fileName);
    if (!file.open(QFile::ReadOnly | QFile::Text)) {
        QMessageBox::warning(this, tr("KD Chart Serializer"),
                             tr("Cannot read file %1:\n%2.")
                                     .arg(fileName)
                                     .arg(file.errorString()));
        return;
    }

    // note: We do NOT set any default data-model for the serializer here
    //       because we assign the data-models by another way, see below.
    KDChart::Serializer serializer( 0, 0 );

    if( serializer.read( &file ) ){
        if( serializer.chart() &&
            serializer.chart()->coordinatePlane() &&
            serializer.chart()->coordinatePlane()->diagram() )
        {
            // Retrieve the chart read from file:
            KDChart::Chart* newChart = serializer.chart();

            // Remove the current chart and delete it:
            removeTheChart();

            KDChart::CoordinatePlaneList planes( newChart->coordinatePlanes() );
            for( int iPlane=0; iPlane<planes.count(); ++iPlane){
                KDChart::AbstractDiagramList diags( planes.at(iPlane)->diagrams() );
                for( int iDiag=0; iDiag<diags.count(); ++iDiag){
                    KDChart::AbstractDiagram* diagram = diags.at( iDiag );
                    if( dynamic_cast<KDChart::BarDiagram*>( diagram ) ||
                        dynamic_cast<KDChart::LineDiagram*>( diagram ) )
                        diagram->setModel( m_model );
                }
            }

            // From now on use the chart read from file:
            m_chart = newChart;
            m_chartLayout->addWidget( m_chart );

            m_chart->update();
        }else{
            QMessageBox::warning( this, tr("KD Chart Serializer"),
                                  tr("ERROR: Parsed chart in file %1 has no diagram.")
                                  .arg(fileName) );
        }
    }else{
        QMessageBox::warning( this, tr("KD Chart Serializer"),
                              tr("ERROR: Cannot read file %1.")
                              .arg(fileName) );
    }
    file.close();
}
unsigned int	ImageBase::bitsPerPlane() const {
	return bitsPerPixel() / planes();
}