Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
image_analysis.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef PAGESPEED_KERNEL_IMAGE_IMAGE_ANALYSIS_H_
20 #define PAGESPEED_KERNEL_IMAGE_IMAGE_ANALYSIS_H_
21 
22 #include <cstddef>
25 
26 namespace net_instaweb {
27 class MessageHandler;
28 }
29 
30 namespace pagespeed {
31 
32 namespace image_compression {
33 
34 class ScanlineReaderInterface;
36 
37 const int kNumColorHistogramBins = 256;
38 
49 bool SobelGradient(const uint8_t* image, int width, int height,
50  int bytes_per_line, PixelFormat pixel_format,
51  MessageHandler* handler, uint8_t* gradient);
52 
58 void Histogram(const uint8_t* image, int width, int height, int bytes_per_line,
59  int x0, int y0, float* hist);
60 
69 float PhotoMetric(const uint8_t* image, int width, int height,
70  int bytes_per_line, PixelFormat pixel_format, float threshold,
71  MessageHandler* handler);
72 
76 float WidestPeakWidth(const float* hist, float threshold);
77 
81 bool IsPhoto(ScanlineReaderInterface* reader, MessageHandler* handler);
82 
89 bool AnalyzeImage(ImageFormat image_type,
90  const void* image_buffer,
91  size_t buffer_length,
92  int* width,
93  int* height,
94  bool* is_progressive,
95  bool* is_animated,
96  bool* has_transparency,
97  bool* is_photo,
98  int* quality,
99  ScanlineReaderInterface** reader,
100  MessageHandler* handler);
101 
102 }
103 
104 }
105 
106 #endif
Definition: message_handler.h:39