| 2844 | ////////////////////// B A C K P R O J E C T P A T C H ///////////////////////// |
| 2845 | |
| 2846 | CV_IMPL void |
| 2847 | cvCalcArrBackProjectPatch( CvArr** arr, CvArr* dst, CvSize patch_size, CvHistogram* hist, |
| 2848 | int method, double norm_factor ) |
| 2849 | { |
| 2850 | CvHistogram* model = 0; |
| 2851 | |
| 2852 | IplImage imgstub[CV_MAX_DIM], *img[CV_MAX_DIM]; |
| 2853 | IplROI roi; |
| 2854 | CvMat dststub, *dstmat; |
| 2855 | int i, dims; |
| 2856 | int x, y; |
| 2857 | CvSize size; |
| 2858 | |
| 2859 | if( !CV_IS_HIST(hist)) |
| 2860 | CV_Error( CV_StsBadArg, "Bad histogram pointer" ); |
| 2861 | |
| 2862 | if( !arr ) |
| 2863 | CV_Error( CV_StsNullPtr, "Null double array pointer" ); |
| 2864 | |
| 2865 | if( norm_factor <= 0 ) |
| 2866 | CV_Error( CV_StsOutOfRange, |
| 2867 | "Bad normalization factor (set it to 1.0 if unsure)" ); |
| 2868 | |
| 2869 | if( patch_size.width <= 0 || patch_size.height <= 0 ) |
| 2870 | CV_Error( CV_StsBadSize, "The patch width and height must be positive" ); |
| 2871 | |
| 2872 | dims = cvGetDims( hist->bins ); |
| 2873 | cvNormalizeHist( hist, norm_factor ); |
| 2874 | |
| 2875 | for( i = 0; i < dims; i++ ) |
| 2876 | { |
| 2877 | CvMat stub, *mat; |
| 2878 | mat = cvGetMat( arr[i], &stub, 0, 0 ); |
| 2879 | img[i] = cvGetImage( mat, &imgstub[i] ); |
| 2880 | img[i]->roi = &roi; |
| 2881 | } |
| 2882 | |
| 2883 | dstmat = cvGetMat( dst, &dststub, 0, 0 ); |
| 2884 | if( CV_MAT_TYPE( dstmat->type ) != CV_32FC1 ) |
| 2885 | CV_Error( CV_StsUnsupportedFormat, "Resultant image must have 32fC1 type" ); |
| 2886 | |
| 2887 | if( dstmat->cols != img[0]->width - patch_size.width + 1 || |
| 2888 | dstmat->rows != img[0]->height - patch_size.height + 1 ) |
| 2889 | CV_Error( CV_StsUnmatchedSizes, |
| 2890 | "The output map must be (W-w+1 x H-h+1), " |
| 2891 | "where the input images are (W x H) each and the patch is (w x h)" ); |
| 2892 | |
| 2893 | cvCopyHist( hist, &model ); |
| 2894 | |
| 2895 | size = cvGetMatSize(dstmat); |
| 2896 | roi.coi = 0; |
| 2897 | roi.width = patch_size.width; |
| 2898 | roi.height = patch_size.height; |
| 2899 | |
| 2900 | for( y = 0; y < size.height; y++ ) |
| 2901 | { |
| 2902 | for( x = 0; x < size.width; x++ ) |
| 2903 | { |
nothing calls this directly
no test coverage detected