[FFmpeg-devel] [PATCH] lavfi/vf_colorconstancy: add weighted_greyedge

2018-09-30 Thread Mina

Hi,

  This patch was part of GSoC Color Constancy filter. It introduces an 
improved color constancy filter(weighted_greyedge) based on the already 
pushed greyedge. I'm sending it again after updating it against latest 
version of master.


Regards,
Mina Sami

>From 33b92a766ff575c9765c15097cdda19a2e9e9e60 Mon Sep 17 00:00:00 2001
From: Mina 
Date: Sun, 30 Sep 2018 21:32:17 +0200
Subject: [PATCH] lavfi/vf_colorconstancy: add weighted_greyedge

Signed-off-by: Mina 
---
 doc/filters.texi|  39 
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_colorconstancy.c | 322 
 4 files changed, 288 insertions(+), 75 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 6d3833317e..f00ee4781c 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -17526,6 +17526,45 @@ separatefields,select=eq(mod(n,4),0)+eq(mod(n,4),3),weave
 @end example
 @end itemize
 
+@section weighted_greyedge
+A color constancy variation filter which estimates scene illumination via weighted grey edge
+algorithm and corrects the scene colors accordingly.
+
+See: @url{http://refbase.cvc.uab.es/files/GGW2012.pdf}
+
+The filter accepts the following options:
+
+@table @option
+@item minknorm
+The Minkowski parameter to be used for calculating the Minkowski distance. Must
+be chosen in the range [1,20] and default value is 1.
+
+@item sigma
+The standard deviation of Gaussian blur to be applied on the scene. Must be
+chosen in the range [0.2,1024.0] and default value = 1.
+
+@item wmap_k
+The power applied to the weight map to emphasis heigher weights. Must be chosen
+in the range [1,20] and default value = 2.
+
+@item iters
+The max number of iterations for performing the algorithm. Must be chosen in the
+range [1,20] and default value = 5.
+
+@item angerr
+The angular error threshold in degrees for stoping the algorithm. Must be chosen
+in the range [0,360] and default value = 0.001.
+@end table
+
+@subsection Examples
+@itemize
+
+@item
+@example
+weighted_greyedge=minknorm=5:sigma=2:wmap_k=10:iters=10:angerr=0.0005
+@end example
+@end itemize
+
 @section xbr
 Apply the xBR high-quality magnification filter which is designed for pixel
 art. It follows a set of edge-detection rules, see
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 62cc2f561f..f9626d4e16 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -400,6 +400,7 @@ OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o framesync.o
 OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o
 OBJS-$(CONFIG_WAVEFORM_FILTER)   += vf_waveform.o
 OBJS-$(CONFIG_WEAVE_FILTER)  += vf_weave.o
+OBJS-$(CONFIG_WEIGHTED_GREYEDGE_FILTER)  += vf_colorconstancy.o
 OBJS-$(CONFIG_XBR_FILTER)+= vf_xbr.o
 OBJS-$(CONFIG_YADIF_FILTER)  += vf_yadif.o
 OBJS-$(CONFIG_ZMQ_FILTER)+= f_zmq.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 5e72803b13..095da84151 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -381,6 +381,7 @@ extern AVFilter ff_vf_vstack;
 extern AVFilter ff_vf_w3fdif;
 extern AVFilter ff_vf_waveform;
 extern AVFilter ff_vf_weave;
+extern AVFilter ff_vf_weighted_greyedge;
 extern AVFilter ff_vf_xbr;
 extern AVFilter ff_vf_yadif;
 extern AVFilter ff_vf_zmq;
diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c
index e3bb39e51b..3b84a637c7 100644
--- a/libavfilter/vf_colorconstancy.c
+++ b/libavfilter/vf_colorconstancy.c
@@ -26,6 +26,14 @@
  *
  * @cite
  * J. van de Weijer, Th. Gevers, A. Gijsenij "Edge-Based Color Constancy".
+ *
+ * @cite
+ *  J. van de Weijer, Th. Gevers, and J. Geusebroek,
+ * “Edge and corner detection by photometric quasi-invariants”.
+ *
+ * @cite
+ * A. Gijsenij, Th. Gevers, J. van de Weijer,
+ * "Improving Color Constancy by Photometric Edge Weighting".
  */
 
 #include "libavutil/imgutils.h"
@@ -39,7 +47,8 @@
 
 #include 
 
-#define GREY_EDGE "greyedge"
+#define GREY_EDGE  "greyedge"
+#define WEIGHTED_GREY_EDGE "weighted_greyedge"
 
 #define SQRT3 1.73205080757
 
@@ -79,6 +88,10 @@ typedef struct ColorConstancyContext {
 int minknorm; /**< @minknorm = 0 : getMax instead */
 double sigma;
 
+int wmap_k;
+int iters;
+double angerr_thresh;
+
 int nb_threads;
 int planeheight[4];
 int planewidth[4];
@@ -477,53 +490,73 @@ static int filter_slice_grey_edge(AVFilterContext* ctx, void* arg, int jobnr, in
 }
 
 /**
- * Main control function for grey edge algorithm.
+ * Slice function for weighted grey edge algorithm that is called iteratively to
+ * calculate and apply weight scheme.
  *
  * @param ctx the filter context.
- * @param in frame to perfrom grey edge on.
+ * @param arg data to be passed between threads.
+ * @param jobnr current job nubmer.
+ * @para

Re: [FFmpeg-devel] Mentoring project: music test source

2018-09-30 Thread Mina



On 09/30/2018 07:41 PM, Nicolas George wrote:

Hi.

For the next rounds of sponsored internships, I would like to propose
the following project, that I would mentor:

A music-like audio lavfi source for testing purposes.

That means a deterministic pseudo-random stream of notes with varied
frequencies, with a structure that looks like music


Do you mean by "look like music" to just follow music theory rules or 
actually sound like real music.

Just curious.


  and would trigger
the same pathways in filters and codecs.

It would be based on asrc_sine, which already has a fast bit-exact
sinusoidal signal generator. On top of that, the filter would change the
frequency randomly to make notes according to a tempo, preferably by
following harmony rules, and would shape the note with an envelope and
harmonics.

As qualification tasks, I can propose:

- make a "musicalscale" filter source that outputs the audible spectrum
   of notes in sequence;

- make a filter source that sounds like a percussion instrument hit
   repeatedly at a regular interval.

What do you think of it, in terms of usefulness and difficulty?

Regards,



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavfi/vf_colorconstancy: add weighted_greyedge

2018-10-01 Thread Mina



On 10/01/2018 12:24 PM, Moritz Barsnick wrote:

+The standard deviation of Gaussian blur to be applied on the scene. Must be

  ^ to



Done.


+The power applied to the weight map to emphasis heigher weights. Must be chosen

   ^ emphasize


British spelling but done.


+The angular error threshold in degrees for stoping the algorithm. Must be 
chosen

   ^ stopping



Done.


+ * @cite
+ *  J. van de Weijer, Th. Gevers, and J. Geusebroek,
+ * ???Edge and corner detection by photometric quasi-invariants???.

   ^^^
You should fix the quotation marks here.


Done.


- * @return 0 in case of success, a negative value corresponding to an
- * AVERROR code in case of failure.
+ * @return 0.
   */
-static int filter_grey_edge(AVFilterContext *ctx, AVFrame *in)
+static int filter_slice_weighted_grey_edge(AVFilterContext* ctx, void* arg, 
int jobnr, int nb_jobs)

If it only ever returns 0, you can probably make it void - unless it
will be expanded later to require a return code.


AVFilterInternal::execute expects such type of the function.



Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2] lavfi/vf_colorconstancy: add weighted_greyedge

2018-10-01 Thread Mina

Hi,

  This patch was part of GSoC Color Constancy filter. It introduces an 
improved color constancy filter(weighted_greyedge) based on the already 
pushed greyedge. I'm sending it again after updating it against latest 
version of master.


V2 changes:
- fixed some spelling mistakes in filters.texi
- fixed some text format error in filters.texi


Regards,
Mina Sami

>From 158159a2137d104763875718f1c217c472b12fa5 Mon Sep 17 00:00:00 2001
From: Mina 
Date: Mon, 1 Oct 2018 18:06:41 +0200
Subject: [PATCH] lavfi/vf_colorconstancy: add weighted_greyedge

Signed-off-by: Mina 
---
 doc/filters.texi|  39 
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_colorconstancy.c | 322 
 4 files changed, 288 insertions(+), 75 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 6d3833317e..d2b0ef024b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -17526,6 +17526,45 @@ separatefields,select=eq(mod(n,4),0)+eq(mod(n,4),3),weave
 @end example
 @end itemize
 
+@section weighted_greyedge
+A color constancy variation filter which estimates scene illumination via weighted grey edge
+algorithm and corrects the scene colors accordingly.
+
+See: @url{http://refbase.cvc.uab.es/files/GGW2012.pdf}
+
+The filter accepts the following options:
+
+@table @option
+@item minknorm
+The Minkowski parameter to be used for calculating the Minkowski distance. Must
+be chosen in the range [1,20] and default value is 1.
+
+@item sigma
+The standard deviation of Gaussian blur to be applied to the scene. Must be
+chosen in the range [0.2,1024.0] and default value = 1.
+
+@item wmap_k
+The power applied to the weight map to emphasize heigher weights. Must be chosen
+in the range [1,20] and default value = 2.
+
+@item iters
+The max number of iterations for performing the algorithm. Must be chosen in the
+range [1,20] and default value = 5.
+
+@item angerr
+The angular error threshold in degrees for stopping the algorithm. Must be chosen
+in the range [0,360] and default value = 0.001.
+@end table
+
+@subsection Examples
+@itemize
+
+@item
+@example
+weighted_greyedge=minknorm=5:sigma=2:wmap_k=10:iters=10:angerr=0.0005
+@end example
+@end itemize
+
 @section xbr
 Apply the xBR high-quality magnification filter which is designed for pixel
 art. It follows a set of edge-detection rules, see
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 62cc2f561f..f9626d4e16 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -400,6 +400,7 @@ OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o framesync.o
 OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o
 OBJS-$(CONFIG_WAVEFORM_FILTER)   += vf_waveform.o
 OBJS-$(CONFIG_WEAVE_FILTER)  += vf_weave.o
+OBJS-$(CONFIG_WEIGHTED_GREYEDGE_FILTER)  += vf_colorconstancy.o
 OBJS-$(CONFIG_XBR_FILTER)+= vf_xbr.o
 OBJS-$(CONFIG_YADIF_FILTER)  += vf_yadif.o
 OBJS-$(CONFIG_ZMQ_FILTER)+= f_zmq.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 5e72803b13..095da84151 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -381,6 +381,7 @@ extern AVFilter ff_vf_vstack;
 extern AVFilter ff_vf_w3fdif;
 extern AVFilter ff_vf_waveform;
 extern AVFilter ff_vf_weave;
+extern AVFilter ff_vf_weighted_greyedge;
 extern AVFilter ff_vf_xbr;
 extern AVFilter ff_vf_yadif;
 extern AVFilter ff_vf_zmq;
diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c
index e3bb39e51b..28b466f89a 100644
--- a/libavfilter/vf_colorconstancy.c
+++ b/libavfilter/vf_colorconstancy.c
@@ -26,6 +26,14 @@
  *
  * @cite
  * J. van de Weijer, Th. Gevers, A. Gijsenij "Edge-Based Color Constancy".
+ *
+ * @cite
+ *  J. van de Weijer, Th. Gevers, and J. Geusebroek,
+ * "Edge and corner detection by photometric quasi-invariants".
+ *
+ * @cite
+ * A. Gijsenij, Th. Gevers, J. van de Weijer,
+ * "Improving Color Constancy by Photometric Edge Weighting".
  */
 
 #include "libavutil/imgutils.h"
@@ -39,7 +47,8 @@
 
 #include 
 
-#define GREY_EDGE "greyedge"
+#define GREY_EDGE  "greyedge"
+#define WEIGHTED_GREY_EDGE "weighted_greyedge"
 
 #define SQRT3 1.73205080757
 
@@ -79,6 +88,10 @@ typedef struct ColorConstancyContext {
 int minknorm; /**< @minknorm = 0 : getMax instead */
 double sigma;
 
+int wmap_k;
+int iters;
+double angerr_thresh;
+
 int nb_threads;
 int planeheight[4];
 int planewidth[4];
@@ -477,53 +490,73 @@ static int filter_slice_grey_edge(AVFilterContext* ctx, void* arg, int jobnr, in
 }
 
 /**
- * Main control function for grey edge algorithm.
+ * Slice function for weighted grey edge algorithm that is called iteratively to
+ * calculate and apply weight scheme.
  *
  * @param ctx the filter context.
- * @param in frame to perfrom

Re: [FFmpeg-devel] Mentoring project: music test source

2018-10-07 Thread Mina



On 10/04/2018 11:40 AM, Nicolas George wrote:

Hi.

No need to Cc people who are on the list.


Actually replied only to you initially, sorry about that.



Mina (2018-09-30):

Do you mean by "look like music" to just follow music theory rules or
actually sound like real music.
Just curious.

In my mind, the purpose is to have a signal that can exercise filters
and codecs, trigger as many code paths as possible, without requiring an
external sample.

Therefore, it must "look like music" from the point of view of analysis
done by filters and codecs. And since some of the have quite subtle
psychoacoustic models tweaked for music, following music theory rules is
probably a requirement.

Sounding like real music seems much more difficult, and possibly not
that useful. But I think that if the code is clean, if somebody comes up
with a better algorithm to sound more catchy, it can be added in the
same filter as an option.

And, to answer Carl Eugen's question: No, I do not have a student lined
for this project.

Regards,



I think I can start on that, I was already searching for my next 
contribution. Pedro's reply seems pretty useful.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2] lavfi/vf_colorconstancy: add weighted_greyedge

2018-10-13 Thread Mina



On 10/01/2018 06:09 PM, Mina wrote:

Hi,

  This patch was part of GSoC Color Constancy filter. It introduces an 
improved color constancy filter(weighted_greyedge) based on the 
already pushed greyedge. I'm sending it again after updating it 
against latest version of master.


V2 changes:
- fixed some spelling mistakes in filters.texi
- fixed some text format error in filters.texi


Regards,
Mina Sami



A gentle ping.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2] lavfi/vf_colorconstancy: add weighted_greyedge

2018-12-03 Thread Mina


On 11/28/18 11:24 PM, Moritz Barsnick wrote:

On Mon, Oct 01, 2018 at 18:09:46 +0200, Mina wrote:

Nit:



Thanks for your feedback and sorry for late response.





+be chosen in the range [1,20] and default value is 1.

[...]



Not sure what is here.



+chosen in the range [0.2,1024.0] and default value = 1.

A bit inconsistent here, with "is" vs. "=".



Done, changed to "=".



+The max number of iterations for performing the algorithm. Must be chosen in 
the

^ maximum



Done, changed to "maximum".




I can't comment on the rest.

Cheers,
Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v3] lavfi/vf_colorconstancy: add weighted_greyedge

2018-12-03 Thread Mina

Hi,

  This patch was part of GSoC Color Constancy filter. It introduces an 
improved color constancy filter(weighted_greyedge) based on the already 
pushed greyedge. I'm sending it again after updating it against latest 
version of master.


V3 changes:
- fixed inconsistency in filters.texi


Regards,
Mina Sami

>From f4891ca38470893d29864821cd1988bb026cf160 Mon Sep 17 00:00:00 2001
From: Mina 
Date: Tue, 4 Dec 2018 00:22:23 +0200
Subject: [PATCH] lavfi/vf_colorconstancy: add weighted_greyedge

Signed-off-by: Mina 
---
 doc/filters.texi|  39 
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_colorconstancy.c | 322 
 4 files changed, 288 insertions(+), 75 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 41fbbc5329..1cad919ba7 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -18038,6 +18038,45 @@ separatefields,select=eq(mod(n,4),0)+eq(mod(n,4),3),weave
 @end example
 @end itemize
 
+@section weighted_greyedge
+A color constancy variation filter which estimates scene illumination via weighted grey edge
+algorithm and corrects the scene colors accordingly.
+
+See: @url{http://refbase.cvc.uab.es/files/GGW2012.pdf}
+
+The filter accepts the following options:
+
+@table @option
+@item minknorm
+The Minkowski parameter to be used for calculating the Minkowski distance. Must
+be chosen in the range [1,20] and default value = 1.
+
+@item sigma
+The standard deviation of Gaussian blur to be applied to the scene. Must be
+chosen in the range [0.2,1024.0] and default value = 1.
+
+@item wmap_k
+The power applied to the weight map to emphasize heigher weights. Must be chosen
+in the range [1,20] and default value = 2.
+
+@item iters
+The maximum number of iterations for performing the algorithm. Must be chosen in the
+range [1,20] and default value = 5.
+
+@item angerr
+The angular error threshold in degrees for stopping the algorithm. Must be chosen
+in the range [0,360] and default value = 0.001.
+@end table
+
+@subsection Examples
+@itemize
+
+@item
+@example
+weighted_greyedge=minknorm=5:sigma=2:wmap_k=10:iters=10:angerr=0.0005
+@end example
+@end itemize
+
 @section xbr
 Apply the xBR high-quality magnification filter which is designed for pixel
 art. It follows a set of edge-detection rules, see
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 6e2658186d..d77ca697b2 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -414,6 +414,7 @@ OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o framesync.o
 OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o
 OBJS-$(CONFIG_WAVEFORM_FILTER)   += vf_waveform.o
 OBJS-$(CONFIG_WEAVE_FILTER)  += vf_weave.o
+OBJS-$(CONFIG_WEIGHTED_GREYEDGE_FILTER)  += vf_colorconstancy.o
 OBJS-$(CONFIG_XBR_FILTER)+= vf_xbr.o
 OBJS-$(CONFIG_XSTACK_FILTER) += vf_stack.o framesync.o
 OBJS-$(CONFIG_YADIF_FILTER)  += vf_yadif.o yadif_common.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index a600069500..7dbfccb393 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -392,6 +392,7 @@ extern AVFilter ff_vf_vstack;
 extern AVFilter ff_vf_w3fdif;
 extern AVFilter ff_vf_waveform;
 extern AVFilter ff_vf_weave;
+extern AVFilter ff_vf_weighted_greyedge;
 extern AVFilter ff_vf_xbr;
 extern AVFilter ff_vf_xstack;
 extern AVFilter ff_vf_yadif;
diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c
index e3bb39e51b..3b84a637c7 100644
--- a/libavfilter/vf_colorconstancy.c
+++ b/libavfilter/vf_colorconstancy.c
@@ -26,6 +26,14 @@
  *
  * @cite
  * J. van de Weijer, Th. Gevers, A. Gijsenij "Edge-Based Color Constancy".
+ *
+ * @cite
+ *  J. van de Weijer, Th. Gevers, and J. Geusebroek,
+ * “Edge and corner detection by photometric quasi-invariants”.
+ *
+ * @cite
+ * A. Gijsenij, Th. Gevers, J. van de Weijer,
+ * "Improving Color Constancy by Photometric Edge Weighting".
  */
 
 #include "libavutil/imgutils.h"
@@ -39,7 +47,8 @@
 
 #include 
 
-#define GREY_EDGE "greyedge"
+#define GREY_EDGE  "greyedge"
+#define WEIGHTED_GREY_EDGE "weighted_greyedge"
 
 #define SQRT3 1.73205080757
 
@@ -79,6 +88,10 @@ typedef struct ColorConstancyContext {
 int minknorm; /**< @minknorm = 0 : getMax instead */
 double sigma;
 
+int wmap_k;
+int iters;
+double angerr_thresh;
+
 int nb_threads;
 int planeheight[4];
 int planewidth[4];
@@ -477,53 +490,73 @@ static int filter_slice_grey_edge(AVFilterContext* ctx, void* arg, int jobnr, in
 }
 
 /**
- * Main control function for grey edge algorithm.
+ * Slice function for weighted grey edge algorithm that is called iteratively to
+ * calculate and apply weight scheme.
  *
  * @param ctx the filter context.
- * @param in frame to perfrom grey edge on.
+ * @param arg

Re: [FFmpeg-devel] [PATCH 1/2] libavfilter/vf_colorconstancy.c : Cleanup code for new filter

2020-06-28 Thread Mina


On 6/18/20 3:52 PM, Yatendra Singh wrote:

Signed-off-by: Yatendra Singh 
---
  libavfilter/vf_colorconstancy.c | 47 ++---
  1 file changed, 14 insertions(+), 33 deletions(-)

LGTM
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] libavfilter/vf_colorconstancy.c : Adding weighted greyedge

2020-06-28 Thread Mina


On 6/18/20 3:52 PM, Yatendra Singh wrote:

Signed-off-by: Yatendra Singh 
---
  doc/filters.texi|  36 ++
  libavfilter/Makefile|   1 +
  libavfilter/allfilters.c|   1 +
  libavfilter/vf_colorconstancy.c | 215 
  4 files changed, 253 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 85a511b205..2946b5b9e6 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -20250,6 +20250,42 @@ 
separatefields,select=eq(mod(n,4),0)+eq(mod(n,4),3),weave
  @end example
  @end itemize
  
+@section weighted_greyedge

+Apply the color constancy filter which estimates illumination and updates the
+image colors accordingly.
+
+It accepts the following options:
+
+@table @option
+@item minknorm
+The Minkowski parameter to be used for calculating the Minkowski distance. Must
+be chosen in the range [0,20] and default value is 1. Set to 0 for getting
+max value instead of calculating Minkowski distance.
+
+@item sigma
+The standard deviation of Gaussian blur to be applied on the scene. Must be
+chosen in the range [0,1024.0] and default value = 1. floor( @var{sigma} * 
break_off_sigma(3) )
+can't be equal to 0 if @var{difford} is greater than 0.
+
+@item min_err
+The error angle between the estimated illumination and white light at which 
the algorithm stops even
+if it hasn't reached the required number of iterations @code{max_iters}. Must 
be chosen in the range
+[0.02,PI] radians with default of 0.1.
+
+@item max_iters
+The number of iterations at which the algorithm stops even if it hasn't 
reached the required
+error angle between the estimated illumination and white light @code{min_err}. 
Must be chosen in the
+range [1,100] with a default value of 10.
+
+@item kappa
+The power which is applied to the spectral weights to change the impact of 
weights on illuminant
+estimation @code{kappa}. Must be chosen in the range [1,25] with a default 
value of 10.
+@end table
+
+@example
+ffmpeg -i mondrian.tif -vf 
"weighted_greyedge=minknorm=0:sigma=1:max_iters=50:min_err=0.02:kappa=10" 
mondrian_out.tif
+@end example
+
  @section xbr
  Apply the xBR high-quality magnification filter which is designed for pixel
  art. It follows a set of edge-detection rules, see
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 994a4172a3..6973452f8d 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -453,6 +453,7 @@ OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o 
framesync.o
  OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o
  OBJS-$(CONFIG_WAVEFORM_FILTER)   += vf_waveform.o
  OBJS-$(CONFIG_WEAVE_FILTER)  += vf_weave.o
+OBJS-$(CONFIG_WEIGHTED_GREYEDGE_FILTER)  += vf_colorconstancy.o
  OBJS-$(CONFIG_XBR_FILTER)+= vf_xbr.o
  OBJS-$(CONFIG_XFADE_FILTER)  += vf_xfade.o
  OBJS-$(CONFIG_XFADE_OPENCL_FILTER)   += vf_xfade_opencl.o opencl.o 
opencl/xfade.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index f2a44b0090..ad2e07f9c5 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -432,6 +432,7 @@ extern AVFilter ff_vf_vstack;
  extern AVFilter ff_vf_w3fdif;
  extern AVFilter ff_vf_waveform;
  extern AVFilter ff_vf_weave;
+extern AVFilter ff_vf_weighted_greyedge;
  extern AVFilter ff_vf_xbr;
  extern AVFilter ff_vf_xfade;
  extern AVFilter ff_vf_xfade_opencl;
diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c
index d36400bd35..e2e32b7ca3 100644
--- a/libavfilter/vf_colorconstancy.c
+++ b/libavfilter/vf_colorconstancy.c
@@ -1,5 +1,6 @@
  /*
   * Copyright (c) 2018 Mina Sami
+ * Copyright (c) 2020 Yatendra Singh
   *
   * This file is part of FFmpeg.
   *
@@ -26,6 +27,14 @@
   *
   * @cite
   * J. van de Weijer, Th. Gevers, A. Gijsenij "Edge-Based Color Constancy".
+ *
+ * @cite
+ * J. van de Weijer, Th. Gevers, and J. Geusebroek,
+ * “Edge and corner detection by photometric quasi-invariants”.
+ *
+ * @cite
+ * A. Gijsenij, Th. Gevers, J. van de Weijer,
+ * "Improving Color Constancy by Photometric Edge Weighting".
   */
  
  #include "libavutil/imgutils.h"

@@ -40,8 +49,10 @@
  #include 
  
  #define GREY_EDGE "greyedge"

+#define WEIGHTED_GREY_EDGE "weighted_greyedge"
  
  #define SQRT3 1.73205080757

+#define NORMAL_WHITE 1/SQRT3
  
  #define NUM_PLANES3

  #define MAX_DIFF_ORD  2
@@ -77,12 +88,16 @@ typedef struct ColorConstancyContext {
  
  int difford;

  int minknorm; /**< @minknorm = 0 : getMax instead */
+int kappa;
  double sigma;
  
  int nb_threads;

  int planeheight[4];
  int planewidth[4];
  
+double min_err;

+int max_iters;
+
  int filtersize;
  double *gauss[MAX_DIFF_ORD+1];
  
@@ -608,6 +623,162 @@ static void chromatic_adaptation(AVFilterContext *ctx, AVFrame *in, AVFrame *out

  ctx->internal->execute(ctx, diagonal_tr

Re: [FFmpeg-devel] [PATCH v3] lavfi/vf_colorconstancy: add weighted_greyedge

2019-09-22 Thread Mina

Hi,

I have been very busy last year but recently things are settling down 
and I would be glad to resume contributing.


FYI, a contest was held earlier this year that resulted in some great 
papers/variations, so I can either resend an updated patch or refactor 
the filter to accommodate for those possible new variations.


Cheers,
Mina Sami

On 9/22/19 3:13 PM, Paul B Mahol wrote:

Is this gonna be applied at all?

On 12/3/18, Mina  wrote:

Hi,

This patch was part of GSoC Color Constancy filter. It introduces an
improved color constancy filter(weighted_greyedge) based on the already
pushed greyedge. I'm sending it again after updating it against latest
version of master.

V3 changes:
- fixed inconsistency in filters.texi


Regards,
Mina Sami



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avfilter/vf_colorconstancy: fix overreads in gauss array

2019-10-12 Thread Mina


On 10/12/19 11:09 AM, Paul B Mahol wrote:

Fixes #8250

Signed-off-by: Paul B Mahol 
---
  libavfilter/vf_colorconstancy.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c
index e3bb39e51b..cc081e957f 100644
--- a/libavfilter/vf_colorconstancy.c
+++ b/libavfilter/vf_colorconstancy.c
@@ -280,7 +280,7 @@ static int slice_get_derivative(AVFilterContext* ctx, void* 
arg, int jobnr, int
  dst[INDX2D(r, c, width)] = 0;
  for (g = 0; g < filtersize; ++g) {
  dst[INDX2D(r, c, width)] += GAUSS(src, r, 
   c + GINDX(filtersize, g),
-  in_linesize, height, 
width, gauss[GINDX(filtersize, g)]);
+  in_linesize, height, 
width, gauss[g]);
  }
  }
  }
@@ -295,7 +295,7 @@ static int slice_get_derivative(AVFilterContext* ctx, void* 
arg, int jobnr, int
  dst[INDX2D(r, c, width)] = 0;
  for (g = 0; g < filtersize; ++g) {
  dst[INDX2D(r, c, width)] += GAUSS(src, r + 
GINDX(filtersize, g), c,
-  width, height, 
width, gauss[GINDX(filtersize, g)]);
+  width, height, 
width, gauss[g]);
  }
  }
  }



LGTM

Thanks,
Mina

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH][GSoC] srcnn - an image super resolution filter using CNN

2018-03-22 Thread Mina

Hi,
  This patch is introduced as a qualification task required by Super 
Resolution project for GSoC. It passes patchcheck and make fate and 
doesn't introduce new warnings. It's implemented by the help of the 
mentor: Pedro Arthur. It's been tested over 7 images of which 6 got 
expected results while 1 didn't.

Used command for testing:
ffmpeg -i input_image -vf "scale=2*iw:2*ih,format=yuv420p,srcnn" 
output_image.


Attached is the patch and here is a link <https://imgur.com/a/pTZTm> for 
3 images with their results; one of which is the one with incorrect result.
Please check(the problem maybe in the way I am copying the image) and 
share some feedback or guidance about what the problem may be and what 
should I do next regarding the GSoC proposal as I haven't submitted one 
yet. Is there any template/requirements for proposal? Also note that the 
algorithm runs convolution without multi-threading on cpu as simple 
while loops so it's slow for large images. Performance be improved later 
on.


Best regards,
Mina Sami.

>From 2ac25e4456a3ce9a16f688cce590da2521ff4703 Mon Sep 17 00:00:00 2001
From: MinaBombo 
Date: Thu, 22 Mar 2018 16:53:22 +0200
Subject: [PATCH] Added srcnn filter

---
 Changelog   |   1 +
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/srcnn_weights.h | 290 
 libavfilter/vf_srcnn.c  | 261 +++
 5 files changed, 554 insertions(+)
 create mode 100644 libavfilter/srcnn_weights.h
 create mode 100644 libavfilter/vf_srcnn.c

diff --git a/Changelog b/Changelog
index c1b9df4..e153f12 100644
--- a/Changelog
+++ b/Changelog
@@ -46,6 +46,7 @@ version :
   They can be found at http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git
 - native SBC encoder and decoder
 - drmeter audio filter
+- Added image SRCNN(Super Resolution Convolutional Neural Network) filter. No training yet.
 
 
 version 3.4:
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index fc16512..b37a956 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -323,6 +323,7 @@ OBJS-$(CONFIG_SMARTBLUR_FILTER)  += vf_smartblur.o
 OBJS-$(CONFIG_SOBEL_FILTER)  += vf_convolution.o
 OBJS-$(CONFIG_SPLIT_FILTER)  += split.o
 OBJS-$(CONFIG_SPP_FILTER)+= vf_spp.o
+OBJS-$(CONFIG_SRCNN_FILTER)  += vf_srcnn.o
 OBJS-$(CONFIG_SSIM_FILTER)   += vf_ssim.o framesync.o
 OBJS-$(CONFIG_STEREO3D_FILTER)   += vf_stereo3d.o
 OBJS-$(CONFIG_STREAMSELECT_FILTER)   += f_streamselect.o framesync.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index cc423af..42f409c 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -332,6 +332,7 @@ static void register_all(void)
 REGISTER_FILTER(SOBEL,  sobel,  vf);
 REGISTER_FILTER(SPLIT,  split,  vf);
 REGISTER_FILTER(SPP,spp,vf);
+REGISTER_FILTER(SRCNN,  srcnn,  vf);
 REGISTER_FILTER(SSIM,   ssim,   vf);
 REGISTER_FILTER(STEREO3D,   stereo3d,   vf);
 REGISTER_FILTER(STREAMSELECT,   streamselect,   vf);
diff --git a/libavfilter/srcnn_weights.h b/libavfilter/srcnn_weights.h
new file mode 100644
index 000..6497b1e
--- /dev/null
+++ b/libavfilter/srcnn_weights.h
@@ -0,0 +1,290 @@
+/*
+ * Copyright (c) 2018 Mina Sami
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Super resolution filter pretrained weights
+ *
+ * @see https://arxiv.org/abs/1501.00092
+ */
+
+#ifndef AVFILTER_SRCNN_WEIGHTS_H
+#define AVFILTER_SRCNN_WEIGHTS_H
+
+const int ff_cnn_num_filters[] = {
+1, 64, 32, 1
+};
+
+const int ff_cnn_size_filters[] = {
+1, 9, 1, 5
+};
+
+static const float weights1_64x81[] = {
+-0.088663,0.05541,0.037197,-0.11961,-0.12342,0.29963,-0.091182,-0.00013614,-0.049024,0.038421,-0.077268,0.027273,0.45762,0.023582,-0.20364,-0.077384,0.072884,0.066799,-0.073151,0.26653,0.078364,-0.28985,-0.50691,0.044665,-0.062469,-0.024425,-0.029073,-0.16885,0.20686,-0.25367,-0.385,-0.12602,0.72579,0.095884,-0.044873,-0.011252,-0

[FFmpeg-devel] [Patch][GSoC] srcnn - a super resolution filter using CNN

2018-03-25 Thread Mina

Hi,

  This patch is introduced as a qualification task required by Super 
Resolution project for GSoC. It passes patchcheck and make fate, doesn't 
introduce new warnings and gives expected results for all tested images. 
It's implemented by the help of the mentor: Pedro Arthur.


Best regards,
Mina Sami.

>From bf8ac38cee36886f6c317681a16aecfa5dee0752 Mon Sep 17 00:00:00 2001
From: MinaBombo 
Date: Sat, 24 Mar 2018 21:15:08 +0200
Subject: [PATCH] Added srcnn filter

---
 Changelog   |   1 +
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/srcnn_weights.h | 290 
 libavfilter/vf_srcnn.c  | 264 
 5 files changed, 557 insertions(+)
 create mode 100644 libavfilter/srcnn_weights.h
 create mode 100644 libavfilter/vf_srcnn.c

diff --git a/Changelog b/Changelog
index c1b9df4..e153f12 100644
--- a/Changelog
+++ b/Changelog
@@ -46,6 +46,7 @@ version :
   They can be found at http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git
 - native SBC encoder and decoder
 - drmeter audio filter
+- Added image SRCNN(Super Resolution Convolutional Neural Network) filter. No training yet.
 
 
 version 3.4:
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index fc16512..b37a956 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -323,6 +323,7 @@ OBJS-$(CONFIG_SMARTBLUR_FILTER)  += vf_smartblur.o
 OBJS-$(CONFIG_SOBEL_FILTER)  += vf_convolution.o
 OBJS-$(CONFIG_SPLIT_FILTER)  += split.o
 OBJS-$(CONFIG_SPP_FILTER)+= vf_spp.o
+OBJS-$(CONFIG_SRCNN_FILTER)  += vf_srcnn.o
 OBJS-$(CONFIG_SSIM_FILTER)   += vf_ssim.o framesync.o
 OBJS-$(CONFIG_STEREO3D_FILTER)   += vf_stereo3d.o
 OBJS-$(CONFIG_STREAMSELECT_FILTER)   += f_streamselect.o framesync.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index cc423af..42f409c 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -332,6 +332,7 @@ static void register_all(void)
 REGISTER_FILTER(SOBEL,  sobel,  vf);
 REGISTER_FILTER(SPLIT,  split,  vf);
 REGISTER_FILTER(SPP,spp,vf);
+REGISTER_FILTER(SRCNN,  srcnn,  vf);
 REGISTER_FILTER(SSIM,   ssim,   vf);
 REGISTER_FILTER(STEREO3D,   stereo3d,   vf);
 REGISTER_FILTER(STREAMSELECT,   streamselect,   vf);
diff --git a/libavfilter/srcnn_weights.h b/libavfilter/srcnn_weights.h
new file mode 100644
index 000..d6ac79c
--- /dev/null
+++ b/libavfilter/srcnn_weights.h
@@ -0,0 +1,290 @@
+/*
+ * Copyright (c) 2018 Mina Sami
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Super resolution filter pretrained weights
+ *
+ * @see https://arxiv.org/abs/1501.00092
+ */
+
+#ifndef AVFILTER_SRCNN_WEIGHTS_H
+#define AVFILTER_SRCNN_WEIGHTS_H
+
+const int ff_cnn_num_filters[] = {
+1, 64, 32, 1
+};
+
+const int ff_cnn_size_filters[] = {
+1, 9, 1, 5
+};
+
+static const float weights1_64x81[] = {
+-0.088663,0.05541,0.037197,-0.11961,-0.12342,0.29963,-0.091182,-0.00013614,-0.049024,0.038421,-0.077268,0.027273,0.45762,0.023582,-0.20364,-0.077384,0.072884,0.066799,-0.073151,0.26653,0.078364,-0.28985,-0.50691,0.044665,-0.062469,-0.024425,-0.029073,-0.16885,0.20686,-0.25367,-0.385,-0.12602,0.72579,0.095884,-0.044873,-0.011252,-0.029559,0.22117,-0.38453,-0.05351,0.10956,0.37257,-0.28968,-0.10884,0.19629,0.097468,-0.0056471,-0.13036,0.62543,0.19104,-0.011692,-0.27068,-0.030754,0.029876,0.016809,-0.18318,-0.16016,0.35983,-0.1889,-0.22343,-0.2,0.32211,-0.18514,-0.06647,0.18006,-0.03566,-0.25352,-0.1837,0.28395,0.0030237,0.24073,-0.14355,0.047419,-0.032212,-0.088013,0.29592,0.041087,-0.10354,-0.11681,-0.010267,0.023704,
+-0.043954,0.095339,0.12234,-0.052115,0.068812,0.057649,0.086867,-0.12001,0.023536,-0.022271,-0.063779,0.010644,-0.27824,-0.2372,-0.21418,-0.09665,0.10459,0.065994,-0.031174,-0.034654,0.022144,-0.24322,-0.089236,-0.027248,-0.093149,-0.03741,0.078197,0.12521,0.1119,0.34982,0.24304,0.21351,0.37121,0.12193,-0.15492,0.01884,-0.083511,-0.3055,-0.11462,-0.1

[FFmpeg-devel] [GSoC] proposal idea: Color Constancy using Machine Learning

2018-03-26 Thread Mina

Hi,

  I'm proposing a Color Constancy filter as a project idea for GSoC and 
was asking for any remarks about that idea.


  Color constancy is the ability of the human visual system that 
ensures the perception of the color of objects to remain relatively 
constant under varying illumination conditions. A color constancy filter 
would basically be applied on images with various degrees of damage to 
restore original colors as close as possible.


This <https://imgur.com/a/hj2ox> is a simple example of a low-statistics 
filter output I've implemented as an academic project along with the 
original damaged image. The filter is an implementation of a 
mathematical equation presented with some parameters that's used to 
introduce variations to the filter.


  Use cases: despite being an end-result filter that helps retrieving 
damaged images original colors it's very helpful as a pre-processing 
utility for many computer vision algorithms. A simple example would be a 
classifier that identifies an object utilizing its color.


Implementation: this is still a research filed where last paper I've 
read was out earlier this year and still more and more papers are being 
published introducing various learning-methods to improve accuracy 
including unsupervised and supervised methods and even new 
learning-based algorithms to improve low-statistics light-computational 
ones. Variations of this filter and their accuracies will also prove to 
be a very appropriate project for GSoC since there is many factors 
affecting the choice of filter such as real-time need, filed of 
application, available dataset, ..etc. So, it's more like a group of 
filters.


  Impact: introduction of machine learning to this filed is quiet 
recent so enhancing FFmpeg with this technology and possibly adding to 
it will prove entrepreneurship. Photography, Computer Vision and many 
other fields that performs fine image processing would make good use of 
this filter.


Best regards,
Mina Sami.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [Patch][GSoC] srcnn - a super resolution filter using CNN

2018-04-13 Thread Mina

Hi,

  I haven't received any feedback regarding this qualification task 
whether it's accepted or not. So, with less than 10 days left for GSoC, 
I thought I was ask for any reviews about my task so that I can fix it 
if anything needs fixing. Thanks in advance.


Best regards,
Mina Sami.


On 03/25/2018 10:27 AM, Mina wrote:

Hi,

  This patch is introduced as a qualification task required by Super 
Resolution project for GSoC. It passes patchcheck and make fate, 
doesn't introduce new warnings and gives expected results for all 
tested images. It's implemented by the help of the mentor: Pedro Arthur.


Best regards,
Mina Sami.



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH][GSOC] avfilter: added colorconstancy

2018-07-13 Thread Mina

Hi,

  This patch introduces Grey-Edge algorithm as part of the Color 
Constancy Filter project in GSOC.


Best regards,
Mina Sami

>From 75ff45f28690cf208058315e4a3ec48e7981b837 Mon Sep 17 00:00:00 2001
From: Mina 
Date: Thu, 12 Jul 2018 20:19:55 +0200
Subject: [PATCH] avfilter: added colorconstancy

Signed-off-by: Mina 
---
 Changelog   |   1 +
 MAINTAINERS |   1 +
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_colorconstancy.c | 808 
 5 files changed, 812 insertions(+)
 create mode 100644 libavfilter/vf_colorconstancy.c

diff --git a/Changelog b/Changelog
index e43a159b0d..dfdb2f38af 100644
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,7 @@ version :
 - libtensorflow backend for DNN based filters like srcnn
 - vc1 decoder is now bit-exact
 - ATRAC9 decoder
+- colorconstancy filter
 
 
 version 4.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index 78f450dda6..234b655cef 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -332,6 +332,7 @@ Filters:
   vf_bwdif  Thomas Mundt (CC )
   vf_chromakey.cTimo Rothenpieler
   vf_colorchannelmixer.cPaul B Mahol
+  vf_colorconstancy.c   Mina Sami(CC )
   vf_colorbalance.c Paul B Mahol
   vf_colorkey.c Timo Rothenpieler
   vf_colorlevels.c  Paul B Mahol
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 7735c26529..ebe43e1391 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -228,6 +228,7 @@ OBJS-$(CONFIG_FSPP_FILTER)   += vf_fspp.o
 OBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
 OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o
 OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o
+OBJS-$(CONFIG_GREYEDGE_FILTER)   += vf_colorconstancy.o
 OBJS-$(CONFIG_HALDCLUT_FILTER)   += vf_lut3d.o framesync.o
 OBJS-$(CONFIG_HFLIP_FILTER)  += vf_hflip.o
 OBJS-$(CONFIG_HISTEQ_FILTER) += vf_histeq.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 0ded83ede2..9c99b03a81 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -217,6 +217,7 @@ extern AVFilter ff_vf_fspp;
 extern AVFilter ff_vf_gblur;
 extern AVFilter ff_vf_geq;
 extern AVFilter ff_vf_gradfun;
+extern AVFilter ff_vf_greyedge;
 extern AVFilter ff_vf_haldclut;
 extern AVFilter ff_vf_hflip;
 extern AVFilter ff_vf_histeq;
diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c
new file mode 100644
index 00..ec7b2a1832
--- /dev/null
+++ b/libavfilter/vf_colorconstancy.c
@@ -0,0 +1,808 @@
+/*
+ * Copyright (c) 2018 Mina Sami
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Color Constancy filter
+ *
+ * @see http://colorconstancy.com/
+ *
+ * @cite
+ * J. van de Weijer, Th. Gevers, A. Gijsenij "Edge-Based Color Constancy".
+ */
+
+#include "libavutil/avassert.h"
+#include "libavutil/bprint.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+#include 
+
+#define GREY_EDGE "greyedge"
+
+#define NUM_PLANES3
+#define MAX_DIFF_ORD  2
+#define MAX_META_DATA 4
+#define MAX_DATA  4
+
+#define INDEX_TEMP 0
+#define INDEX_DX   1
+#define INDEX_DY   2
+#define INDEX_DXY  3
+#define INDEX_NORM INDEX_DX
+#define INDEX_SRC  0
+#define INDEX_DST  1
+#define INDEX_ORD  2
+#define INDEX_DIR  3
+#define DIR_X 0
+#define DIR_Y 1
+
+/**
+ * Used for passing data between threads.
+ */
+typedef struct ThreadData {
+AVFrame *in, *out;
+int meta_data[MAX_META_DATA];
+double  *data[MAX_DATA][NUM_PLANES];
+} ThreadData;
+
+/**
+ * Common struct for all algorithms contexts.
+ */
+typedef struct ColorConstancyContext {
+const AVClass *class;
+
+int correct;
+int save;
+char *outfile;
+
+int difford;
+int minknorm; /**< @minknorm = 0 : getMax instead */
+double sigm

[FFmpeg-devel] [PATCH v2][GSOC] avfilter: added colorconstancy

2018-07-14 Thread Mina

Hi,

  This patch introduces Grey-Edge algorithm as part of the Color 
Constancy Filter project in GSOC.


V2 changes:
- added documentation ini filters.texi
- remove currently not useful code (saving to file)


Best regards,
Mina Sami

>From deb1cad1bb007b7372dd128581033c5c63b63ee6 Mon Sep 17 00:00:00 2001
From: Mina 
Date: Sun, 15 Jul 2018 04:16:13 +0200
Subject: [PATCH] avfilter: added colorconstancy

Signed-off-by: Mina 
---
 Changelog   |   1 +
 MAINTAINERS |   1 +
 doc/filters.texi|  38 ++
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_colorconstancy.c | 756 
 6 files changed, 798 insertions(+)
 create mode 100644 libavfilter/vf_colorconstancy.c

diff --git a/Changelog b/Changelog
index e43a159b0d..dfdb2f38af 100644
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,7 @@ version :
 - libtensorflow backend for DNN based filters like srcnn
 - vc1 decoder is now bit-exact
 - ATRAC9 decoder
+- colorconstancy filter
 
 
 version 4.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index 78f450dda6..234b655cef 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -332,6 +332,7 @@ Filters:
   vf_bwdif  Thomas Mundt (CC )
   vf_chromakey.cTimo Rothenpieler
   vf_colorchannelmixer.cPaul B Mahol
+  vf_colorconstancy.c   Mina Sami(CC )
   vf_colorbalance.c Paul B Mahol
   vf_colorkey.c Timo Rothenpieler
   vf_colorlevels.c  Paul B Mahol
diff --git a/doc/filters.texi b/doc/filters.texi
index 49895ff947..a787068939 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -9940,6 +9940,44 @@ gradfun=radius=8
 
 @end itemize
 
+@section greyedge
+
+A variation color constancy that estimates scene illumination via grey edge algorithm
+and corrects the scene colors accordingly.
+
+The filter accepts the following options:
+
+@table @option
+@item difford
+The order of diffrentation to be applied on the scene. Must be chosen in the range
+[0,2] and default value is 1.
+
+@item minknorm
+The Minkowski parameter to be used for calculating the Minkowski distance. Must 
+be chosen in the range [0,65535] and default value is 1. Set to 0 for getting
+max value instead of calculating Minkowski distance.
+
+@item sigma
+The standard deviation of Gaussian blur to be applied on the scene. Must be 
+chosen in the range [0,1024.0] and default value = 1. Sigma can't be set to 0
+if @var{difford} is greater than 1.
+
+@subsection Examples
+
+@item
+Grey Edge:
+@example
+greyedge=difford=1:minknorm=5:sigma=2
+@end example
+@end itemize
+
+@item
+Max Edge:
+@example
+greyedge=difford=1:minknorm=0:sigma=2
+@end example
+@end itemize
+
 @anchor{haldclut}
 @section haldclut
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 7735c26529..ebe43e1391 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -228,6 +228,7 @@ OBJS-$(CONFIG_FSPP_FILTER)   += vf_fspp.o
 OBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
 OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o
 OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o
+OBJS-$(CONFIG_GREYEDGE_FILTER)   += vf_colorconstancy.o
 OBJS-$(CONFIG_HALDCLUT_FILTER)   += vf_lut3d.o framesync.o
 OBJS-$(CONFIG_HFLIP_FILTER)  += vf_hflip.o
 OBJS-$(CONFIG_HISTEQ_FILTER) += vf_histeq.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 0ded83ede2..9c99b03a81 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -217,6 +217,7 @@ extern AVFilter ff_vf_fspp;
 extern AVFilter ff_vf_gblur;
 extern AVFilter ff_vf_geq;
 extern AVFilter ff_vf_gradfun;
+extern AVFilter ff_vf_greyedge;
 extern AVFilter ff_vf_haldclut;
 extern AVFilter ff_vf_hflip;
 extern AVFilter ff_vf_histeq;
diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c
new file mode 100644
index 00..281a4cb43d
--- /dev/null
+++ b/libavfilter/vf_colorconstancy.c
@@ -0,0 +1,756 @@
+/*
+ * Copyright (c) 2018 Mina Sami
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+

[FFmpeg-devel] Fwd: Re: [PATCH v2][GSOC] avfilter: added colorconstancy

2018-07-15 Thread Mina




 Forwarded Message 
Subject: 	Re: [FFmpeg-devel] [PATCH v2][GSOC] avfilter: added 
colorconstancy

Date:   Sun, 15 Jul 2018 20:51:09 +0200
From:   Mina 
To: Gyan Doshi 



On 07/15/2018 07:16 AM, Gyan Doshi wrote:


On 15-07-2018 07:50 AM, Mina wrote:



First, thanks for your feedback.

+A variation color constancy that estimates scene illumination via 
grey edge algorithm

+and corrects the scene colors accordingly.


"A variation color constancy filter which estimates ..."


Okay will be changed to "A color constancy variation filter which estimates"



Maybe add a link to the algo paper in the next line:

"Grey Edge algorithm: http://...";


The link I have is to a research paper so I didn't think a non-developer
user would benefit from it but will add it.




> +The order of diffrentation to be applied on the scene. Must be 
chosen in the range


diffrentation -> differentiation


Changed.



> +chosen in the range [0,1024.0] and default value = 1. Sigma can't 
be set to 0

> +if @var{difford} is greater than 1.

but for set_gauss, you say

> Sigma can be zero only at difford = 0

and test during config

> av_assert0(sigma || !s->difford);

Please correct the docs. Also prefer that you log an informational 
error and return AVERROR(EINVAL) instead of an assert.




Sure, will do.



Thanks,
Gyan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] Fwd: Re: [PATCH v2][GSOC] avfilter: added colorconstancy

2018-07-15 Thread Mina




 Forwarded Message 
Subject: 	Re: [FFmpeg-devel] [PATCH v2][GSOC] avfilter: added 
colorconstancy

Date:   Sun, 15 Jul 2018 20:51:51 +0200
From:   Mina 
To: Reto Kromer 



On 07/15/2018 07:22 AM, Reto Kromer wrote:

Hello Mina,

I noticed a typo in the documentation:


@item difford
The order of diffrentation

diffrentation -> differentiation


Thanks for your feedback and it will be corrected.



Best regards, Reto

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v3][GSOC] avfilter: added colorconstancy

2018-07-15 Thread Mina

Hi,

  This patch introduces Grey-Edge algorithm as part of the Color 
Constancy Filter project in GSOC.


V3 changes:
- corrected typo in documentation
- corrected wrong value in documentation
- added link to algorithm research paper in documentation
- returned EINVAL and log error when sigma = 0 && difford > 0 instead of 
assert


Best regards,
Mina Sami

>From 52a0057eda8bf5147b53c9d71089d944ebaa759c Mon Sep 17 00:00:00 2001
From: Mina 
Date: Sun, 15 Jul 2018 20:59:52 +0200
Subject: [PATCH] avfilter: added colorconstancy

Signed-off-by: Mina 
---
 Changelog   |   1 +
 MAINTAINERS |   1 +
 doc/filters.texi|  39 ++
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_colorconstancy.c | 758 
 6 files changed, 801 insertions(+)
 create mode 100644 libavfilter/vf_colorconstancy.c

diff --git a/Changelog b/Changelog
index 72da5bf519..807a05dec9 100644
--- a/Changelog
+++ b/Changelog
@@ -15,6 +15,7 @@ version :
 - vc1 decoder is now bit-exact
 - ATRAC9 decoder
 - lensfun wrapper filter
+- colorconstancy filter
 
 
 version 4.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index 78f450dda6..234b655cef 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -332,6 +332,7 @@ Filters:
   vf_bwdif  Thomas Mundt (CC )
   vf_chromakey.cTimo Rothenpieler
   vf_colorchannelmixer.cPaul B Mahol
+  vf_colorconstancy.c   Mina Sami(CC )
   vf_colorbalance.c Paul B Mahol
   vf_colorkey.c Timo Rothenpieler
   vf_colorlevels.c  Paul B Mahol
diff --git a/doc/filters.texi b/doc/filters.texi
index 9d8f88ddcf..a70f98ac6b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -9940,6 +9940,45 @@ gradfun=radius=8
 
 @end itemize
 
+@section greyedge
+
+A color constancy variation filter which estimates scene illumination via grey edge algorithm
+and corrects the scene colors accordingly.
+See: https://staff.science.uva.nl/th.gevers/pub/GeversTIP07.pdf
+
+The filter accepts the following options:
+
+@table @option
+@item difford
+The order of differentiation to be applied on the scene. Must be chosen in the range
+[0,2] and default value is 1.
+
+@item minknorm
+The Minkowski parameter to be used for calculating the Minkowski distance. Must 
+be chosen in the range [0,65535] and default value is 1. Set to 0 for getting
+max value instead of calculating Minkowski distance.
+
+@item sigma
+The standard deviation of Gaussian blur to be applied on the scene. Must be 
+chosen in the range [0,1024.0] and default value = 1. Sigma can't be set to 0
+if @var{difford} is greater than 0.
+
+@subsection Examples
+
+@item
+Grey Edge:
+@example
+greyedge=difford=1:minknorm=5:sigma=2
+@end example
+@end itemize
+
+@item
+Max Edge:
+@example
+greyedge=difford=1:minknorm=0:sigma=2
+@end example
+@end itemize
+
 @anchor{haldclut}
 @section haldclut
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 5d4549e24c..86b04e3efb 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -228,6 +228,7 @@ OBJS-$(CONFIG_FSPP_FILTER)   += vf_fspp.o
 OBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
 OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o
 OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o
+OBJS-$(CONFIG_GREYEDGE_FILTER)   += vf_colorconstancy.o
 OBJS-$(CONFIG_HALDCLUT_FILTER)   += vf_lut3d.o framesync.o
 OBJS-$(CONFIG_HFLIP_FILTER)  += vf_hflip.o
 OBJS-$(CONFIG_HISTEQ_FILTER) += vf_histeq.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 521bc53164..2d19929bdc 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -217,6 +217,7 @@ extern AVFilter ff_vf_fspp;
 extern AVFilter ff_vf_gblur;
 extern AVFilter ff_vf_geq;
 extern AVFilter ff_vf_gradfun;
+extern AVFilter ff_vf_greyedge;
 extern AVFilter ff_vf_haldclut;
 extern AVFilter ff_vf_hflip;
 extern AVFilter ff_vf_histeq;
diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c
new file mode 100644
index 00..7194688dfa
--- /dev/null
+++ b/libavfilter/vf_colorconstancy.c
@@ -0,0 +1,758 @@
+/*
+ * Copyright (c) 2018 Mina Sami
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General

Re: [FFmpeg-devel] [PATCH v3][GSOC] avfilter: added colorconstancy

2018-07-16 Thread Mina



On 07/16/2018 02:55 AM, Michael Niedermayer wrote:

On Sun, Jul 15, 2018 at 09:13:04PM +0200, Mina wrote:

Hi,

   This patch introduces Grey-Edge algorithm as part of the Color Constancy
Filter project in GSOC.

V3 changes:
- corrected typo in documentation
- corrected wrong value in documentation
- added link to algorithm research paper in documentation
- returned EINVAL and log error when sigma = 0 && difford > 0 instead of
assert

Best regards,
Mina Sami

  Changelog   |1
  MAINTAINERS |1
  doc/filters.texi|   39 ++
  libavfilter/Makefile|1
  libavfilter/allfilters.c|1
  libavfilter/vf_colorconstancy.c |  758 

  6 files changed, 801 insertions(+)
470a6bcd3455fa6802ef290f438632a0b1e0ab6f  
0001-avfilter-added-colorconstancy.patch
 From 52a0057eda8bf5147b53c9d71089d944ebaa759c Mon Sep 17 00:00:00 2001
From: Mina 
Date: Sun, 15 Jul 2018 20:59:52 +0200
Subject: [PATCH] avfilter: added colorconstancy

breaks "make doc/ffprobe-all.html"

HTMLdoc/ffprobe-all.html
doc/filters.texi:9966: @subsection seen before @end table
doc/filters.texi:9968: @item outside of table or list
doc/filters.texi:9973: unmatched `@end itemize'
doc/filters.texi:9975: @item outside of table or list
doc/filters.texi:9980: unmatched `@end itemize'
make: *** [doc/ffprobe-all.html] Error 1

[...]


Hi, thanks for feedback.

Fixed now. Any more edits to be added to v4?




___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v4][GSOC] avfilter: added colorconstancy

2018-07-16 Thread Mina

Hi,

  This patch introduces Grey-Edge algorithm as part of the Color 
Constancy Filter project in GSOC.


V4 changes:
- Fixed error in filter.texi that resulted in breaking "make 
doc/ffprobe-all.html"



Best regards,
Mina Sami

>From 7e24e01bc3a8303e4876b6a455dfc7d933efb6aa Mon Sep 17 00:00:00 2001
From: Mina 
Date: Mon, 16 Jul 2018 10:20:02 +0200
Subject: [PATCH] avfilter: added colorconstancy

Signed-off-by: Mina 
---
 Changelog   |   1 +
 MAINTAINERS |   1 +
 doc/filters.texi|  41 ++
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_colorconstancy.c | 758 
 6 files changed, 803 insertions(+)
 create mode 100644 libavfilter/vf_colorconstancy.c

diff --git a/Changelog b/Changelog
index 72da5bf519..807a05dec9 100644
--- a/Changelog
+++ b/Changelog
@@ -15,6 +15,7 @@ version :
 - vc1 decoder is now bit-exact
 - ATRAC9 decoder
 - lensfun wrapper filter
+- colorconstancy filter
 
 
 version 4.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index 78f450dda6..234b655cef 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -332,6 +332,7 @@ Filters:
   vf_bwdif  Thomas Mundt (CC )
   vf_chromakey.cTimo Rothenpieler
   vf_colorchannelmixer.cPaul B Mahol
+  vf_colorconstancy.c   Mina Sami(CC )
   vf_colorbalance.c Paul B Mahol
   vf_colorkey.c Timo Rothenpieler
   vf_colorlevels.c  Paul B Mahol
diff --git a/doc/filters.texi b/doc/filters.texi
index 705d48e1b0..6e228f76ed 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -9940,6 +9940,47 @@ gradfun=radius=8
 
 @end itemize
 
+@section greyedge
+A color constancy variation filter which estimates scene illumination via grey edge algorithm
+and corrects the scene colors accordingly.
+
+See: @url{https://staff.science.uva.nl/th.gevers/pub/GeversTIP07.pdf}
+
+The filter accepts the following options:
+
+@table @option
+@item difford
+The order of differentiation to be applied on the scene. Must be chosen in the range
+[0,2] and default value is 1.
+
+@item minknorm
+The Minkowski parameter to be used for calculating the Minkowski distance. Must 
+be chosen in the range [0,65535] and default value is 1. Set to 0 for getting
+max value instead of calculating Minkowski distance.
+
+@item sigma
+The standard deviation of Gaussian blur to be applied on the scene. Must be 
+chosen in the range [0,1024.0] and default value = 1. Sigma can't be set to 0
+if @var{difford} is greater than 0.
+@end table
+
+@subsection Examples
+@itemize
+
+@item
+Grey Edge:
+@example
+greyedge=difford=1:minknorm=5:sigma=2
+@end example
+
+@item
+Max Edge:
+@example
+greyedge=difford=1:minknorm=0:sigma=2
+@end example
+
+@end itemize
+
 @anchor{haldclut}
 @section haldclut
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 5d4549e24c..86b04e3efb 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -228,6 +228,7 @@ OBJS-$(CONFIG_FSPP_FILTER)   += vf_fspp.o
 OBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
 OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o
 OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o
+OBJS-$(CONFIG_GREYEDGE_FILTER)   += vf_colorconstancy.o
 OBJS-$(CONFIG_HALDCLUT_FILTER)   += vf_lut3d.o framesync.o
 OBJS-$(CONFIG_HFLIP_FILTER)  += vf_hflip.o
 OBJS-$(CONFIG_HISTEQ_FILTER) += vf_histeq.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 521bc53164..2d19929bdc 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -217,6 +217,7 @@ extern AVFilter ff_vf_fspp;
 extern AVFilter ff_vf_gblur;
 extern AVFilter ff_vf_geq;
 extern AVFilter ff_vf_gradfun;
+extern AVFilter ff_vf_greyedge;
 extern AVFilter ff_vf_haldclut;
 extern AVFilter ff_vf_hflip;
 extern AVFilter ff_vf_histeq;
diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c
new file mode 100644
index 00..7194688dfa
--- /dev/null
+++ b/libavfilter/vf_colorconstancy.c
@@ -0,0 +1,758 @@
+/*
+ * Copyright (c) 2018 Mina Sami
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin S

[FFmpeg-devel] [PATCH] lavfi: update xbr filter url

2018-08-08 Thread Mina

Hi,

  While adding documentation in doc/filters.texi as part of [GSOC]Color 
Constancy Filter project, I found the url for xbr filter giving an 
internal server error. After some search I found another link where the 
author of the filter(and algorithm) posts a tutorial for the algorithm. 
This patch update the existing url with the newly found one.


Thanks,
Mina

>From 1193d48dfbb572ebbe5e3849950079f0af5765ed Mon Sep 17 00:00:00 2001
From: Mina 
Date: Wed, 8 Aug 2018 21:43:18 +0200
Subject: [PATCH] lavfi: update xbr filter url

Signed-off-by: Mina 
---
 doc/filters.texi | 2 +-
 libavfilter/vf_xbr.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 0b0903e5a7..792edfd2e1 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -17148,7 +17148,7 @@ separatefields,select=eq(mod(n,4),0)+eq(mod(n,4),3),weave
 @section xbr
 Apply the xBR high-quality magnification filter which is designed for pixel
 art. It follows a set of edge-detection rules, see
-@url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}.
+@url{https://forums.libretro.com/t/xbr-algorithm-tutorial/123}.
 
 It accepts the following option:
 
diff --git a/libavfilter/vf_xbr.c b/libavfilter/vf_xbr.c
index 78094e0287..2c71871d22 100644
--- a/libavfilter/vf_xbr.c
+++ b/libavfilter/vf_xbr.c
@@ -24,7 +24,7 @@
  * XBR Filter is used for depixelization of image.
  * This is based on Hyllian's xBR shader.
  *
- * @see http://www.libretro.com/forums/viewtopic.php?f=6&t=134
+ * @see https://forums.libretro.com/t/xbr-algorithm-tutorial/123
  * @see https://github.com/yoyofr/iFBA/blob/master/fba_src/src/intf/video/scalers/xbr.cpp
  */
 
-- 
2.17.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [GSOC] [PATCH 1/2] lavfi/vf_colorconstancy: changing options ranges

2018-08-12 Thread Mina

Hi,

  This patch changes the maximum value for minknorm to a more sane 
value and fixes check for sigma value when difford > 0. It also 
itroduces some minor cosmetic edits(spaces and so).


Thanks.

>From 8f4270e4aad285a8652e1831e828439cdb13620a Mon Sep 17 00:00:00 2001
From: Mina 
Date: Mon, 13 Aug 2018 01:29:28 +0200
Subject: [PATCH 1/2] lavfi/vf_colorconstancy: changing options ranges

Signed-off-by: Mina 
---
 doc/filters.texi|  6 +++---
 libavfilter/vf_colorconstancy.c | 20 ++--
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index d6c15837f2..267bd04a43 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -9955,13 +9955,13 @@ The order of differentiation to be applied on the scene. Must be chosen in the r
 
 @item minknorm
 The Minkowski parameter to be used for calculating the Minkowski distance. Must
-be chosen in the range [0,65535] and default value is 1. Set to 0 for getting
+be chosen in the range [0,20] and default value is 1. Set to 0 for getting
 max value instead of calculating Minkowski distance.
 
 @item sigma
 The standard deviation of Gaussian blur to be applied on the scene. Must be
-chosen in the range [0,1024.0] and default value = 1. Sigma can't be set to 0
-if @var{difford} is greater than 0.
+chosen in the range [0,1024.0] and default value = 1. floor( @var{sigma} * break_off_sigma(3) )
+can't be euqal to 0 if @var{difford} is greater than 0.
 @end table
 
 @subsection Examples
diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c
index 7194688dfa..e3bb39e51b 100644
--- a/libavfilter/vf_colorconstancy.c
+++ b/libavfilter/vf_colorconstancy.c
@@ -28,7 +28,6 @@
  * J. van de Weijer, Th. Gevers, A. Gijsenij "Edge-Based Color Constancy".
  */
 
-#include "libavutil/bprint.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
@@ -42,6 +41,8 @@
 
 #define GREY_EDGE "greyedge"
 
+#define SQRT3 1.73205080757
+
 #define NUM_PLANES3
 #define MAX_DIFF_ORD  2
 #define MAX_META_DATA 4
@@ -145,7 +146,7 @@ static int set_gauss(AVFilterContext *ctx)
 sum1 = 0.0;
 for (i = 0; i < filtersize; ++i) {
 s->gauss[1][i] = - (GINDX(filtersize, i) / pow(sigma, 2)) * s->gauss[0][i];
-sum1 += s->gauss[1][i] *GINDX(filtersize, i);
+sum1 += s->gauss[1][i] * GINDX(filtersize, i);
 }
 
 for (i = 0; i < filtersize; ++i) {
@@ -595,7 +596,6 @@ static int diagonal_transformation(AVFilterContext *ctx, void *arg, int jobnr, i
 ThreadData *td = arg;
 AVFrame *in = td->in;
 AVFrame *out = td->out;
-double sqrt3 = pow(3.0, 0.5);
 int plane;
 
 for (plane = 0; plane < NUM_PLANES; ++plane) {
@@ -610,7 +610,7 @@ static int diagonal_transformation(AVFilterContext *ctx, void *arg, int jobnr, i
 unsigned i;
 
 for (i = slice_start; i < slice_end; ++i) {
-temp = src[i] / (s->white[plane] * sqrt3);
+temp = src[i] / (s->white[plane] * SQRT3);
 dst[i] = av_clip_uint8((int)(temp + 0.5));
 }
 }
@@ -657,12 +657,12 @@ static int config_props(AVFilterLink *inlink)
 double sigma = s->sigma;
 int ret;
 
-if (!sigma && s->difford) {
-av_log(ctx, AV_LOG_ERROR, "Sigma can't be set to 0 when difford > 0.\n");
+if (!floor(break_off_sigma * sigma + 0.5) && s->difford) {
+av_log(ctx, AV_LOG_ERROR, "floor(%f * sigma) must be > 0 when difford > 0.\n", break_off_sigma);
 return AVERROR(EINVAL);
 }
 
-s->filtersize = 2 * floor(break_off_sigma * s->sigma + 0.5) + 1;
+s->filtersize = 2 * floor(break_off_sigma * sigma + 0.5) + 1;
 if (ret=set_gauss(ctx)) {
 return ret;
 }
@@ -735,9 +735,9 @@ static const AVFilterPad colorconstancy_outputs[] = {
 #if CONFIG_GREYEDGE_FILTER
 
 static const AVOption greyedge_options[] = {
-{ "difford",  "set differentiation order", OFFSET(difford),  AV_OPT_TYPE_INT,{.i64=1},   0,   2,  FLAGS },
-{ "minknorm", "set Minkowski norm",OFFSET(minknorm), AV_OPT_TYPE_INT,{.i64=1},   0,   65535,  FLAGS },
-{ "sigma","set sigma", OFFSET(sigma),AV_OPT_TYPE_DOUBLE, {.dbl=1},   0.0, 1024.0, FLAGS },
+{ "difford",  "set differentiation order", OFFSET(difford),  AV_OPT_TYPE_INT,{.i64=1}, 0,   2,  FLAGS },
+{ "minknorm", "set Minkowski norm",OFFSET(minknorm), AV_OPT_TYPE_INT,{.i64=1}, 0,   20, FLAGS },
+{ "sigma","set sigma", OFFSET(sigma),AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.0, 1024.0, FLAGS },
 { NULL }
 };
 
-- 
2.17.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [GSOC] [PATCH 1/2] lavfi/vf_colorconstancy: adding weighted_ greyedge

2018-08-12 Thread Mina

Hi,

  This patch introduces a new improved color constancy algorithm based 
on previously implemented greyedge algorithm.


Thanks.

>From ec68204b9b081e0f0861ab50767c41559ed7e7b6 Mon Sep 17 00:00:00 2001
From: Mina 
Date: Mon, 13 Aug 2018 01:49:24 +0200
Subject: [PATCH 2/2] lavfi/vf_colorconstancy: adding weighted_ greyedge

Signed-off-by: Mina 
---
 doc/filters.texi|  39 
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_colorconstancy.c | 322 
 4 files changed, 288 insertions(+), 75 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 267bd04a43..07dacec831 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -17154,6 +17154,45 @@ separatefields,select=eq(mod(n,4),0)+eq(mod(n,4),3),weave
 @end example
 @end itemize
 
+@section weighted_greyedge
+A color constancy variation filter which estimates scene illumination via weighted grey edge
+algorithm and corrects the scene colors accordingly.
+
+See: @url{http://refbase.cvc.uab.es/files/GGW2012.pdf}
+
+The filter accepts the following options:
+
+@table @option
+@item minknorm
+The Minkowski parameter to be used for calculating the Minkowski distance. Must
+be chosen in the range [1,20] and default value is 1.
+
+@item sigma
+The standard deviation of Gaussian blur to be applied on the scene. Must be
+chosen in the range [0.2,1024.0] and default value = 1.
+
+@item wmap_k
+The power applied to the weight map to emphasis heigher weights. Must be chosen
+in the range [1,20] and default value = 2.
+
+@item iters
+The max number of iterations for performing the algorithm. Must be chosen in the
+range [1,20] and default value = 5.
+
+@item angerr
+The angular error threshold in degrees for stoping the algorithm. Must be chosen
+in the range [0,360] and default value = 0.001.
+@end table
+
+@subsection Examples
+@itemize
+
+@item
+@example
+weighted_greyedge=minknorm=5:sigma=2:wmap_k=10:iters=10:angerr=0.0005
+@end example
+@end itemize
+
 @section xbr
 Apply the xBR high-quality magnification filter which is designed for pixel
 art. It follows a set of edge-detection rules, see
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index e5d3a57af7..4086e941fa 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -392,6 +392,7 @@ OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o framesync.o
 OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o
 OBJS-$(CONFIG_WAVEFORM_FILTER)   += vf_waveform.o
 OBJS-$(CONFIG_WEAVE_FILTER)  += vf_weave.o
+OBJS-$(CONFIG_WEIGHTED_GREYEDGE_FILTER)  += vf_colorconstancy.o
 OBJS-$(CONFIG_XBR_FILTER)+= vf_xbr.o
 OBJS-$(CONFIG_YADIF_FILTER)  += vf_yadif.o
 OBJS-$(CONFIG_ZMQ_FILTER)+= f_zmq.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 9732ae5345..8c088e2c1e 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -373,6 +373,7 @@ extern AVFilter ff_vf_vstack;
 extern AVFilter ff_vf_w3fdif;
 extern AVFilter ff_vf_waveform;
 extern AVFilter ff_vf_weave;
+extern AVFilter ff_vf_weighted_greyedge;
 extern AVFilter ff_vf_xbr;
 extern AVFilter ff_vf_yadif;
 extern AVFilter ff_vf_zmq;
diff --git a/libavfilter/vf_colorconstancy.c b/libavfilter/vf_colorconstancy.c
index e3bb39e51b..3b84a637c7 100644
--- a/libavfilter/vf_colorconstancy.c
+++ b/libavfilter/vf_colorconstancy.c
@@ -26,6 +26,14 @@
  *
  * @cite
  * J. van de Weijer, Th. Gevers, A. Gijsenij "Edge-Based Color Constancy".
+ *
+ * @cite
+ *  J. van de Weijer, Th. Gevers, and J. Geusebroek,
+ * “Edge and corner detection by photometric quasi-invariants”.
+ *
+ * @cite
+ * A. Gijsenij, Th. Gevers, J. van de Weijer,
+ * "Improving Color Constancy by Photometric Edge Weighting".
  */
 
 #include "libavutil/imgutils.h"
@@ -39,7 +47,8 @@
 
 #include 
 
-#define GREY_EDGE "greyedge"
+#define GREY_EDGE  "greyedge"
+#define WEIGHTED_GREY_EDGE "weighted_greyedge"
 
 #define SQRT3 1.73205080757
 
@@ -79,6 +88,10 @@ typedef struct ColorConstancyContext {
 int minknorm; /**< @minknorm = 0 : getMax instead */
 double sigma;
 
+int wmap_k;
+int iters;
+double angerr_thresh;
+
 int nb_threads;
 int planeheight[4];
 int planewidth[4];
@@ -477,53 +490,73 @@ static int filter_slice_grey_edge(AVFilterContext* ctx, void* arg, int jobnr, in
 }
 
 /**
- * Main control function for grey edge algorithm.
+ * Slice function for weighted grey edge algorithm that is called iteratively to
+ * calculate and apply weight scheme.
  *
  * @param ctx the filter context.
- * @param in frame to perfrom grey edge on.
+ * @param arg data to be passed between threads.
+ * @param jobnr current job nubmer.
+ * @param nb_jobs total number of jobs.
  *
- * @return 0 in case of success, a negative value corresponding to an
- * AVERROR code in

Re: [FFmpeg-devel] [PATCH][GSOC] avfilter: added colorconstancy

2018-07-13 Thread Mina Samy
On Fri, Jul 13, 2018 at 12:10 PM, Gyan Doshi  wrote:

>
>
> On 13-07-2018 02:44 PM, Mina wrote:
>
>>
>>This patch introduces Grey-Edge algorithm as part of the Color
>> Constancy Filter project in GSOC.
>>
>
> Docs missing.
>
>
The filter isn't completely finished yet and documentation is planed before
the GSOC duration is finished.


> Regards,
> Gyan
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel