OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_GFX_CONTENT_ANALYSIS_H_ |
| 6 #define UI_GFX_CONTENT_ANALYSIS_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "third_party/skia/include/core/SkColor.h" |
| 12 #include "ui/base/ui_export.h" |
| 13 #include "ui/gfx/rect.h" |
| 14 #include "ui/gfx/size.h" |
| 15 |
| 16 class SkBitmap; |
| 17 |
| 18 namespace color_utils { |
| 19 |
| 20 // Compute in-place gaussian gradient magnitude of |input_bitmap| with sigma |
| 21 // |kernel_sigma|. |input_bitmap| is requried to be of SkBitmap::kA8_Config |
| 22 // type. The routine computes first-order gaussian derivative on a |
| 23 // gaussian-smoothed image. Beware, this is fairly slow since kernel size is |
| 24 // 4 * kernel_sigma + 1. |
| 25 UI_EXPORT void ApplyGaussianGradientMagnitudeFilter( |
| 26 SkBitmap* input_bitmap, |
| 27 float kernel_sigma); |
| 28 |
| 29 // Accumulates vertical and horizontal sum of pixel values from a subsection of |
| 30 // |input_bitmap| defined by |image_area|. The image is required to be of |
| 31 // SkBitmap::kA8_Config type. |
| 32 // If non-empty |target_size| is given, the routine will use it to process the |
| 33 // profiles with closing operator sized to eliminate gaps which would be smaller |
| 34 // than 1 pixel after rescaling to |target_size|. |
| 35 // If |apply_log| is true, logarithm of counts are used for morhology (and |
| 36 // returned). |
| 37 UI_EXPORT void ExtractImageProfileInformation(const SkBitmap& input_bitmap, |
| 38 const gfx::Rect& image_area, |
| 39 const gfx::Size& target_size, |
| 40 bool apply_log, |
| 41 std::vector<float>* rows, |
| 42 std::vector<float>* columns); |
| 43 |
| 44 // Compute a threshold value separating background (low) from signal (high) |
| 45 // areas in the |input| profile. |
| 46 UI_EXPORT float AutoSegmentPeaks(const std::vector<float>& input); |
| 47 |
| 48 // Shrinks the source |bitmap| by removing rows and columns where |rows| and |
| 49 // |columns| are false, respectively. The function returns a new bitmap if the |
| 50 // shrinking can be performed and null otherwise. |
| 51 UI_EXPORT SkBitmap* ComputeDecimatedImage(const SkBitmap& bitmap, |
| 52 const std::vector<bool>& rows, |
| 53 const std::vector<bool>& columns); |
| 54 |
| 55 // Creates a new bitmap which contains only 'interesting' areas of |
| 56 // |source_bitmap|. The |target_size| is used to estimate some computation |
| 57 // parameters, but the resulting bitmap will not necessarily be of that size. |
| 58 // |kernel_sigma| defines the degree of image smoothing in gradient computation. |
| 59 // For a natural-sized (not shrunk) screenshot at 96 DPI and regular font size |
| 60 // 5.0 was determined to be a good value. |
| 61 UI_EXPORT SkBitmap* CreateRetargettedThumbnailImage( |
| 62 const SkBitmap& source_bitmap, |
| 63 const gfx::Size& target_size, |
| 64 float kernel_sigma); |
| 65 } // namespace color_utils |
| 66 |
| 67 #endif // UI_GFX_CONTENT_ANALYSIS_H_ |
OLD | NEW |