In our project we are interested in the manipulation of HSLA images

Related tags

Image mmm
Overview
Projet 1
HSLA Images

Réalisé par : Adil Erraad,Said El Ouardi

Link to another page.

HSLA Images

Introduction

Dans le cadre de notre projet nous nous sommes intéressés à la manipulation IMAGES HSLA (HSLA :(Hue, saturation, luminance)). A titre d’exemple le niveau de gris et illini de l’image …etc.

HSL

HSL is short for Hue, Saturation and Luminance. The HSL color space defines colors more naturally: Hue specifies the base color, the other two values then let you specify the saturation of that color and how bright the color should be.

Experiment Image


HSLP

//image header

class Image:public PNG
{
public:
  using PNG::PNG;
  Image(string);
  void saturate(double amount=0.1);
  void lighten(double amount=0.1);
  void rotateColor(double angle);


};

#endif // IMAGE_H

Hue [0°-360°]

As you can see in the image, hue specifies the color. Hue is normally specified as either degrees ranging from 0° to 360° or as numbers from 0 to 6, in the image at the left side both starting at the 3 o'clock position and measured anti-clockwise.

There are 6 base colors:

Hue Degree° Color
0 red
1 60° yellow
2 120° green
3 180° cyan
4 240° blue
5 300° magneta
6 360° red

*Example [Hue=90°]


// Cpp Code for change the hue by angle=90°:
void Image ::rotateColor(double angle){
   for(unsigned x=0;x<width();x++)
       for(unsigned y=0;y<height();y++){
           HSLAPixel &P=getPixel(x,y);
       P.h+=angle;
       //s'asurer que P.h<360
       while(P.h<360)
           P.h+=360;
       //s'asurer que P.h>360
       while(P.h>360)
           P.h-=360;

       }
}

Saturartion [0%-100%]

After specifying the color using the hue value you can specify the saturation of your color. In the HSL color wheel the saturation specifies the distance from the middle of the wheel. So a saturation value of 0 (0%) means "center of the wheel", i.e. a grey value, whereas a saturation value of 1 (100%) means "at the border of the wheel", where the color is fully saturated.


*Example [Saturation=40%]


// Cpp Code for change the saturartion by amount=40%°:
void Image ::saturate(double amount){
   //parcourir tous mes pixles
       //parcourir tous mes pixles
       for(unsigned x=0;x<width();x++)
           for(unsigned y=0;y<height();y++){
               HSLAPixel &P=getPixel(x,y);
               //augumenter la luminence
               P.s+=amount;
               //ne pas depasser 1
               P.s=(P.s<1)? P.s :1;
               //ne pas depasser 0
               P.s=(P.s<0)? 0: P.s;
   }
}

Luminance [0%-100%]

The third parameter in the HSL color space is the luminance. This lets you specify how "bright" the color should be. 0% means, the brightness is 0, and the color is black. 100% means maximum brightness, and the color is white. If you slowly increase the luminance, you will see the color changing from black at 0% and then through a darker version of your color, to your color in its full brightness at 50%, and then getting brighter until finally it reaches white at 100%.

The following six luminance sliders show you what happens with colors if you change the luminance:


*Example [Luminance=40%]


// Cpp Code for change the luminance by amount=40%°:
void Image ::lighten(double amount){
   //parcourir tous mes pixles
   for(unsigned x=0;x<width();x++)
       for(unsigned y=0;y<height();y++){
           HSLAPixel &P=getPixel(x,y);
           //augumenter la luminence
           P.l+=amount;
           //ne pas depasser 1
           P.l=(P.l<1)? P.l :1;
           //ne pas depasser 0
           P.l=(P.l<0)? 0: P.l;
       }
}

GrayScale

in digital photography, computer-generated imagery, and colorimetry, a grayscale image is one in which the value of each pixel is a single sample representing only an amount of light; that is, it carries only intensity information. Grayscale images, a kind of black-and-white or gray monochrome, are composed exclusively of shades of gray. The contrast ranges from black at the weakest intensity to white at the strongest. So Graycale is Effect of reducing the saturation of each pixel.

*Example


// Cpp Code for change the saturation to 0 to get Grayscale image:
void Grayscale ::Gs(){
   //parcourir tous mes pixles
       //parcourir tous mes pixles
       for(unsigned x=0;x<width();x++)
           for(unsigned y=0;y<height();y++){
               HSLAPixel &P=getPixel(x,y);
               P.s=0;
   }
}
//header
Grayscale::Grayscale(string filemane):Image()
{

readFromFile(filemane);
}

void Grayscale ::Gs(){
   //parcourir tous mes pixles
       //parcourir tous mes pixles
       for(unsigned x=0;x<width();x++)
           for(unsigned y=0;y<height();y++){
               HSLAPixel &P=getPixel(x,y);
               P.s=0;



   }

}

Illiny

It is an effect located on the image that converts each color between blue = 11 and orange = 216 to the closest color between them.

*Example


// Cpp Code for illini:

Illini::Illini(string filemane, int c1, int c2):Image(filemane){
   readFromFile(filemane);
  for(unsigned x=0;x<width();x++)
      for(unsigned y=0;y<height();y++){
      
      // TODO: This implementation does not take a consideration of the 
      // of **cirtulcar** aspect of the hue color
          HSLAPixel &P=getPixel(x,y);
          if(P.h<=c2&&P.h>=c1){
                          if((c2-P.h)<(P.h-c1)){
                              P.h=c2;
                          }else{
                              P.h=c1;
                          }
}
}
}
//header

class Illini:public Image
{

public:
   using Image::Image;
   Illini();
   int color1;
   int color2;

   Illini(string filemane,int color1=11,int color2=216);
   Illini(string);
};

#endif // ILLINI_H

Spotlight

A function that focuses light on a specific point of the image based on coordinates by raising the degree of illumination and partial opacity for the rest of the parts.

*Example Spotlight[500,200]


*change SpotPoint[900,300]


// Cpp Code for Spotlight :

Spotlight::Spotlight(string filemane,int X,int Y):Image(filemane),x(X),y(Y)
{
    for(unsigned x = 0; x < width()  ; x++){
       for(unsigned y = 0; y < height(); y++)
       {
          //reference on the pixel
          HSLAPixel &P = getPixel(x, y);
               double distance=sqrt((x-X)*(x-X)+(y-Y)*(y-Y));
               double dec = 1-distance*0.5/100 ;
               if (distance>160) {
                   dec=0.2;
               }
               P.l = dec*P.l;
             }
}
}

//ChangeSpotPoint by [900,300]
void Spotlight::changeSpotPoint(int centerX, int centerY){


    for(unsigned X = 0; X < width()  ; X++){
       for(unsigned Y = 0; Y < height(); Y++)
       {
          //reference on the pixel
          HSLAPixel &P = getPixel(X, Y);

               double distance1=sqrt((x-X)*(x-X)+(y-Y)*(y-Y));
               double distance=sqrt((X-centerX)*(X-centerX)+(Y-centerY)*(Y-centerY));
               double dec = 1-distance*0.5/100 ;
               double inc = 1-distance1*0.5/100 ;
               if (distance1>160) {
                   inc=0.2;
                }
                P.l =P.l/inc;
               if (distance>160) {
                   dec=0.2;
               }
               P.l = dec*P.l;
               }
               }
               }
//header

class Spotlight:public Image
{
public:
    int x,y;
    Spotlight(string filemane,int x,int y);
    void changeSpotPoint(int x, int y);
};

#endif // SPOTLIGHT_H

Todo : Also finish the Spotlight class
You might also like...
A UIActivityViewController to share images while displaying them as a nice preview.
A UIActivityViewController to share images while displaying them as a nice preview.

PSActivityImageViewController Overview This view controller allows you to share an image the same way as a normal UIActivityViewController would, with

Easily display images, animations, badges and alerts to your macOS application's dock icon

DSFDockTile Easily display images, animations, badges and alerts to your macOS application's dock icon. Why? I was inspired by Neil Sardesai after he

📱iOS app to extract full-resolution video frames as images.
📱iOS app to extract full-resolution video frames as images.

Frame Grabber is a focused, easy-to-use iOS app to extract full-resolution video frames as images. Perfect to capture and share your favorite video mo

Phimp.me - Photo Image Editor and Sharing App. Phimp.me is a Photo App for iOS that aims to replace proprietary photo applications. It offers features such as taking photos, adding filters, editing images and uploading them to social networks.
Convert HEIC images to JPEG format on the Mac

heic2jpeg Convert HEIC images to JPEG format on the Mac A basic tool to convert Apple's obnoxious HEIC format images (as the default photo format for

URLImage is a package that holds an easy way of showing images from an URL.
URLImage is a package that holds an easy way of showing images from an URL.

URLImage Overview URLImage is a package that holds an easy way of showing images from an URL. Usually this processes should take the following process

A Swift library for parsing and drawing SVG images to CoreGraphics contexts.

SwiftDraw A Swift library for parsing and drawing SVG images to CoreGraphics contexts. SwiftDraw can also convert an SVG into Swift source code. Usage

Converts images to a textual representation.

ConsoleApp7 Essentially, this suite of programs converts images to text, which is made to resemble the original image. There are three targets in this

Advanced framework for loading, caching, processing, displaying and preheating images.
Advanced framework for loading, caching, processing, displaying and preheating images.

Advanced framework for loading, caching, processing, displaying and preheating images. This framework is no longer maintained. Programming in Swift? C

Owner
null
AsyncImageExample An example project for AsyncImage. Loading images in SwiftUI article.

AsyncImageExample An example project for AsyncImage. Loading images in SwiftUI article. Note: The project works in Xcode 13.0 beta (13A5154h).

Artem Novichkov 4 Dec 31, 2021
Agrume - 🍋 An iOS image viewer written in Swift with support for multiple images.

Agrume An iOS image viewer written in Swift with support for multiple images. Requirements Swift 5.0 iOS 9.0+ Xcode 10.2+ Installation Use Swift Packa

Jan Gorman 601 Dec 26, 2022
APNGKit is a high performance framework for loading and displaying APNG images in iOS and macOS.

APNGKit is a high performance framework for loading and displaying APNG images in iOS and macOS. It's built on top of a modified version of libpng wit

Wei Wang 2.1k Dec 30, 2022
A lightweight generic cache for iOS written in Swift with extra love for images.

Haneke is a lightweight generic cache for iOS and tvOS written in Swift 4. It's designed to be super-simple to use. Here's how you would initalize a J

Haneke 5.2k Dec 11, 2022
Kingfisher is a powerful, pure-Swift library for downloading and caching images from the web

Kingfisher is a powerful, pure-Swift library for downloading and caching images from the web. It provides you a chance to use a pure-Swift way to work

Wei Wang 20.9k Dec 30, 2022
Image viewer (or Lightbox) with support for local and remote videos and images

Table of Contents Features Focus Browse Rotation Zoom tvOS Setup Installation License Author Features Focus Select an image to enter into lightbox mod

Nes 534 Jan 3, 2023
SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them type-safe to use.

SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them type-safe to use.

null 8.3k Jan 5, 2023
A high-performance image library for downloading, caching, and processing images in Swift.

Features Asynchronous image downloader with priority queuing Advanced memory and database caching using YapDatabase (SQLite) Guarantee of only one ima

Yap Studios 72 Sep 19, 2022
Combine SnapshotTesting images into a single asset

An extension to SnapshotTesting which allows you to create images combining the output of multiple snapshot strategies, assuming they all output to UIImage.

James Sherlock 41 Nov 28, 2022
A simple macOS app to read code from images, written purely in Swift using Vision Framework.

CodeReader A simple macOS app to read code from images, written purely in Swift using Vision Framework. Usage Drag an image Click the convert button R

Md Ibrahim Hassan 44 Nov 20, 2022