//+------------------------------------------------------------------+ //| L1TrendImageDenoise.mq5 | //| Copyright 2000-2026, MetaQuotes Ltd. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2000-2026, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" #include #include //+------------------------------------------------------------------+ //| Convert BMP image to double vectors RGB | //+------------------------------------------------------------------+ bool PreprocessImage(vector &red,vector &green,vector &blue,uint &image_data[],int width,int height) { red.Resize(width*height); green.Resize(width*height); blue.Resize(width*height); for(int y=0; y>16)&0xFF)/255.0; green[offset] = double((clr>>8)&0xFF)/255.0; blue[offset] = double(clr&0xFF)/255.0; } return(true); } //+------------------------------------------------------------------+ //| Clamp value to range | //+------------------------------------------------------------------+ double clamp(double value,double minValue,double maxValue) { return(MathMin(MathMax(value,minValue),maxValue)); } //+------------------------------------------------------------------+ //| Convert double vectors back to image | //+------------------------------------------------------------------+ bool PostprocessImage(const vector &red,const vector&green,const vector &blue,uint &image_data[],int width,int height) { ArrayResize(image_data,width*height); for(int y=0; y | //+------------------------------------------------------------------+ bool L1FilterChannel(vector &channel,int width,int height,double lambda) { vector row; row.Resize(width); //--- rows for(int y=0; y col; col.Resize(height); //--- columns for(int x=0; x red,green,blue; PreprocessImage(red,green,blue,image_data,width,height); //--- perform 4 filters with different lambda double lambda_factors[4] = {0.00001, 0.00005, 0.0001, 0.0002}; vector red_f[4],green_f[4],blue_f[4]; for(int i=0; i<4; i++) { red_f[i] = red; green_f[i] = green; blue_f[i] = blue; //--- L1FilterChannel(red_f[i],width,height,lambda_factors[i]); L1FilterChannel(green_f[i],width,height,lambda_factors[i]); L1FilterChannel(blue_f[i],width,height,lambda_factors[i]); } //--- post processing uint filtered_data1[]; uint filtered_data2[]; uint filtered_data3[]; uint filtered_data4[]; //--- PostprocessImage(red_f[0],green_f[0],blue_f[0],filtered_data1,width,height); PostprocessImage(red_f[1],green_f[1],blue_f[1],filtered_data2,width,height); PostprocessImage(red_f[2],green_f[2],blue_f[2],filtered_data3,width,height); PostprocessImage(red_f[3],green_f[3],blue_f[3],filtered_data4,width,height); //--- show all images: original + 4 filteres CCanvas canvas; canvas.CreateBitmapLabel("Comparison",0,0,width*5,height,COLOR_FORMAT_XRGB_NOALPHA); //--- original for(int y=0; y