can't modify the pixel value
Hi everyone,
I want to smooth an image with opencv/c++,here's my code
newImgMax.at<float>(k,l) = (sum(imgMax, k, l, wmax) / (wmax * wmax));
my function sum works fine,I can edit the result of the function but I can't assign it to a pixel,the function sum returns a float and when I try to assign it to a float variable(not a pixel) I can't too.Any help please ?
proposal: describe, what you're trying to achieve, not where you got stuck. maybe you can show us some general formula, how your smoothing is supposed to work, -- then we can help you getting this into code.
(i.e. acccessing your image with
at<float>()
is for sure the wrong way)I'm implementing the FABEMD(Fast and Adaptive Bidimensional Empirical Mode Decomposition Using Order-Statistics Filter Based Envelope Estimation) Method,it consists in decomposing an image into many BIMFs ,after generating the envelopes(upper(imgMax) and lower(imgMin)) I have to apply an averaging smooth for each one ,newImgMax represents the upper envelope after smoothing and it will be used to calculate the first BIMF :
please, append that to you original question ? (and use the "10101" button , to format code properly)
I am very curious about what you say. could you show us your code more.
I'm implementing the function "sum" which add the pixels of an image here's the code
in the main function I can call and edit the return of the function without any problem
but I CAN'T assign it to a float variable
float tmp =0.0f ; tmp=sum(imgMax, k, l, wmax);
my program crashes afterthis lign
rows / cols problem. you need:
image.at<type>(row,col)
also, e.g. for startedX=0 and startedY=0 you code goes out of bounds. please run a debug build, so it throws proper assertsI dont think so. He added another code
if ((i >= 0 && i < img.size().width) && (j >= 0 && j < img.size().height))
to keep the pairs(i,j) in the bounds. Can you sure that the img's type is float?^^ right, missed that. thanks for the correction !
the function works fine, the program crahsesafter this ligne
and shows me an error "segmentation fault core dumped'