Final Reportttttt
Final Reportttttt
Project Report
On
“COLORSCOPE”
Submitted to:
DR. BABASAHEB TECHNOLOGICAL UNIVERSITY
(DIPLOMA WING)
Submitted by:
Disha Rakesh Takawale (2211974)
Sarthak Abhijit Joshi (2211929)
Samruddhi Mangesh Suryawanshi (2211973)
Under guidance of
Prof. Suchita Yadav
CERTIFICATE
This is to certify that the Project entitled
“ColorScope”
Submitted by:
Disha Rakesh Takawale (2211974)
Sarthak Abhijit Joshi (2211929)
Samruddhi Mangesh Suryawanshi (2211973)
A Bonafide work carried out under the supervision of Prof. Suchita Yadav It is submitted
towards partial fulfillment of the requirement of University of Dr. Babasaheb Ambedkar
Technological University, Lonere for the award of the degree of Diploma in Information
Technology.
External Examiner:
ACKNOWLEDGEMENT
The project presentation opportunity provided by college was indeed a great chance to explore
our full potential and a great opportunity to learn new things and evolve our knowledge and
skills.
We would like to express our deep and sincere gratitude to our guide for their unflagging
support and continuous encouragement throughout the project work. Without their guidance
and persistent help this project would not have been possible.
We are extremely grateful to Mrs. Pranali Bhosale, the Project Coordinator for their support
and advices to get and complete project preparation.
Thanks to our classmates who helped us directly or indirectly to accomplish our work. Finally,
I am also thankful to all staff of Department of Information Technology for their valuable
guidance.
Thank You!
COLORSCOPE
ABSTRACT
This report presents the development and implementation of our color detection project namely
“COLORSCOPE” utilizing JavaScript. The primary objective of this project is to accurately
identify and analyze colors within the uploaded image using computer vision techniques.
The project leverages the capabilities of JavaScript along with HTML5 Canvas API,
FileReader API, and EyeDropper API, to perform color detection tasks. By utilizing the power
of web-based technologies, the project aims to provide a lightweight and accessible solution
for color detection, which can be seamlessly integrated into web applications and platforms.
The report details the methodology employed in the development process, including image
processing techniques, color space conversions, and algorithmic approaches for color
detection.
In conclusion, the color detection project demonstrates the feasibility and effectiveness of
utilizing JavaScript for computer vision tasks, particularly in the context of color analysis. The
findings of this project contribute to the advancement of web-based applications for image
processing and computer vision, opening avenues for further research and development in this
domain.
COLORSCOPE
INDEX
Sr no Contents Page no
1. 01-04
Introduction
2. 05-07
Literature Overview
3. 08-09
SDLC
4. 10-11
Technical Requirements
5. 12-14
Architecture Diagram
6. 15-17
Functionalities and Work Flow
7. 18-20
Libraries
8. 21-30
Implementation
9. 31-35
Snapshots
10. 36-37
Conclusion
11. 38
References
COLORSCOPE
CHAPTER 1: INTRODUCTION
1.1 Overview
In today's digital age, the ability to extract meaningful information from images has become
increasingly important across various domains, from graphic design and digital marketing to
industrial automation and computer vision. One fundamental aspect of image processing is
color detection, which involves identifying and analyzing the colors present within an image.
The Color Detection Project using JavaScript aims to develop a web-based application capable
of automatically detecting colors within uploaded images and generating corresponding color
palettes. Leveraging the power of JavaScript, HTML5 Canvas, and modern web technologies,
this project offers a versatile and accessible solution for color analysis and visualization.
With our website you can easily get color from any part of the image which includes its hex
code and RGB values. A color palette will also be generated after uploading the image which
will contain the dominant colors from the image.
EyeDropper API is also used to get the pixel color and generate its hex code. And also tints are
generated accordingly.
1.3 Objectives
The objectives of a color detection project in JavaScript typically include:
1. Developing an Understanding of Color Models: Gain a thorough understanding of color
models such as RGB (Red, Green, Blue), HSL (Hue, Saturation, Lightness), or HSV (Hue,
Saturation, Value). Understand how colors are represented digitally and how they can be
manipulated programmatically.
2. User Interface Design: Design an intuitive user interface that allows users to upload
images, view the analyzed colors, and interact with the results. Consider usability principles to
ensure a smooth user experience.
1
COLORSCOPE
3. Error Handling and Validation: Implement robust error handling mechanisms to handle
scenarios such as invalid image formats, failed color detection, or unexpected errors. Provide
informative error messages to guide users in troubleshooting issues.
5. Integration with External Libraries or APIs: Explore the use of external libraries or APIs
that provide advanced color analysis capabilities or additional features. This could include the
API of EyeDropper.
6. Testing and Validation: Conduct thorough testing of the color detection functionality to
ensure accuracy and reliability. Test the application with a variety of images to validate its
performance under different conditions and scenarios.
8. More Color generative features: Provide the user with a color palette of dominant color
and also some additional features for adjusting the color code’s RGB values and providing a
new tint as per the user.
1.4 Applications
The applications of color detection are as follows:
1. Image Processing and Editing: Color detection can be used to develop image editing tools
that can automatically adjust brightness, contrast, and saturation levels. It can also be used to
create filters that can change the color tone of an image.
2. Object Detection and Tracking: Color detection can be used in object detection and
tracking applications, such as surveillance systems, to identify and track objects based on their
color.
2
COLORSCOPE
3. Fashion and Beauty: Color detection can be used in fashion and beauty applications, such
as virtual try-on, to detect the color of clothes, skin tone, and hair color.
4. Healthcare: Color detection can be used in healthcare applications, such as skin cancer
detection, to identify abnormal skin lesions based on their color.
5. Quality Control: Color detection can be used in quality control applications, such as food
processing, to detect defects or contaminants based on their color.
6. Art and Design: Color detection can be used in art and design applications, such as color
palette generation, to create harmonious color schemes.
1.5 Motivation
Overall, the motivation behind color detection projects is to leverage technology to solve real-
world problems, enhance user experiences, and open up new possibilities in various fields.
Improving interfaces that rely on color recognition can make technology more accessible. For
example, applications for individuals with color blindness can identify and label colors,
enhancing usability. Detecting colors in natural environments can aid in monitoring changes,
such as water quality assessment or vegetation health analysis. Artists and designers can use
color detection to analyze and replicate color schemes from nature or other works of art,
fostering creativity and innovation.
3
COLORSCOPE
Color detection is a significant area of interest within computer vision and web development,
often utilized in applications such as image processing, user interface design, and accessibility
tools. This overview highlights key concepts, methodologies, and tools used in JavaScript-
based color detection projects.
2.1 Fundamentals of Color Detection:
❖ Color Spaces:
Understanding different color spaces (RGB, HEX) is crucial. RGB is common in web
development, while HSL/HSV can be more intuitive for human perception.
i. RGB (Red Green Blue):
RGB Stands for "Red Green Blue." RGB refers to three hues of light that can be mixed
together to create different colors. Combining red, green, and blue light is the standard
method of producing color images on screens, such as TVs, computer monitors,
and smartphone screens.
The RGB color model is an "additive" model. When 100% of each color is mixed
together, it creates white light. When 0% of each color is combined, no light is generated,
creating black.
ii. Hex Code:
A hex code is made up of six digits---usually preceded by the pound (#) symbol. For
example, here is the hex code for pure black: #000000. The numbers in this code
correspond to the amount of red, green, and blue in the color.
4
COLORSCOPE
The first two digits tell us how much red is in the color, the next two digits are for green,
and the last two are for blue. Black is the absence of color, which is why it's "000000."
There's no red, green, or blue present.
❖ Pixel Manipulation:
Accessing and manipulating image pixels is fundamental, typically done using the HTML5
<canvas> element.
The HTML <canvas> element is used to draw graphics, on the fly, via JavaScript. The
<canvas> element is only a container for graphics. You must use JavaScript to actually
draw the graphics.
Canvas has several methods for drawing paths, boxes, circles, text, and adding images.
Importing images into a canvas is basically a two step process: Get a reference to an
HTMLImageElement object or to another canvas element as a source. It is also possible to
use images by providing a URL. Draw the image on the canvas using the drawImage ()
function. Let's take a look at how to do this.
Canvas is supported by all major browsers.
5
COLORSCOPE
This API allows web applications to use a color picker interface to select a color from the
user's screen. In this code, the EyeDropper API is used to allow users to pick a color from
an uploaded image.
❖ Clipboard API:
This API allows web applications to read and write data to the system clipboard. In this
code, the Clipboard API is used to allow users to copy the color code to their clipboard.
6
COLORSCOPE
CHAPTER 3: SDLC
2.2 Diagram
Phase 2: Design
- Design the architecture of the color detection system.
- Decide on the technologies and libraries to be used (e.g., HTML Canvas for image
processing, JavaScript for logic).
- Plan the user interface for input and output.
- Create a flowchart or diagram outlining the process of color detection.
7
COLORSCOPE
Phase 3: Implementation
- Write JavaScript code to capture input (e.g., from images).
- Develop the user interface using HTML and CSS.
Phase 4: Testing
- Conduct unit tests to ensure individual components work correctly.
- Perform integration testing to verify that different parts of the system work together
seamlessly.
- Gather feedback from users or stakeholders and incorporate necessary changes.
Phase 5: Deployment
- Prepare the application for deployment by optimizing code and resources.
- Ensure proper documentation is provided for users.
8
COLORSCOPE
9
COLORSCOPE
❖ XAMPP
XAMPP is a free and open-source cross-platform web server solution stack package
developed by Apache Friends, consisting mainly of the Apache HTTP Server, MariaDB
database, and interpreters for scripts written in the PHP and Perl programming languages.
Since most actual web server deployments use the same components as XAMPP, it makes
transitioning from a local test server to a live server possible.
❖ Browser Support
You need a browser which supports the EyeDropper API which is used in the website. You
can use browsers like chrome, internet explorer.
10
COLORSCOPE
- User Input: The starting point of the process where the user interacts with the system, by
uploading an image file.
- Upload Image: The process of uploading an image by uploading a file.
- Preprocess Image: Once the image is uploaded, it goes through preprocessing steps such as
resizing to prepare it for color detection.
- Select Region of Interest: The user selects a specific area or region within the preprocessed
image where they want to detect colors.
- Detect Colors: The system analyzes the selected region to detect the presence of colors.
Colors are detected using the JavaScript functionality.
- Display Result: Finally, the detected colors are displayed to the user, which can include color
names, hex codes, or x and y coordinates.
11
COLORSCOPE
This use case diagram provides a high-level overview of the system's functionality and the
interactions between the user and the system. It can be used as a starting point for further
development and refinement of the system.
System
Hover X and Y co
12
COLORSCOPE
Use Cases:
Generate HEX and RGB Code: The user can generate HEX and RGB color codes.
Hover X and Y Coordinates: The system tracks and displays the X and Y coordinates of the
cursor when hovering.
Generate Palette: The user can generate a color palette.
Generate Gradient: The user can generate color gradients.
Generate Tints: The user can generate tints of a color.
System Boundaries:
The system boundary encompasses all the use cases and actors interacting with the system.
13
COLORSCOPE
5.1 Section 1:
This section will contain the following features with the given steps
14
COLORSCOPE
5.2 Section 2:
Gradient Generator:
15
COLORSCOPE
5.3 Section 3:
Tints Generator:
16
COLORSCOPE
CHAPTER 7: LIBRARIES
6.1 jQuery
jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document
traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-
to-use API that works across a multitude of browsers. With a combination of versatility and
extensibility, jQuery has changed the way that millions of people write JavaScript.
The jQuery library is a single JavaScript file, and you reference it with the HTML <script> tag
(notice that the <script> tag should be inside the <head> section):
<head>
<script src="jquery-3.7.1.min.js"></script>
</head>
17
COLORSCOPE
6.2 Clipboard
Copying text to the clipboard shouldn't be hard. It shouldn't require dozens of steps to configure
or hundreds of KBs to load. But most of all, it shouldn't depend on Flash or any bloated
framework.
That's why clipboard.js exists.
The good news is that clipboard.js gracefully degrades if you need to support older browsers.
All you have to do is show a tooltip saying Copied! when success event is called and Press
Ctrl+C to copy when error event is called because the text is already selected.
18
COLORSCOPE
19
COLORSCOPE
CHAPTER 8: IMPLEMENTATION
This chapter provides a detailed overview of the implementation process for the Color
Detection Website project. The project utilizes HTML, CSS, and JavaScript to create an
interactive and user-friendly application with features including a hex and RGB code generator,
hovering X and Y coordinates tracker, palette generator, gradient generator, and tints generator.
20
COLORSCOPE
So basically we created the contact us form and added the following php code to it to process
the queries and save it into database.
There is one file required for the establishing the connection :
21
COLORSCOPE
22
COLORSCOPE
23
COLORSCOPE
findTopDensityCubes Function:
Here's a breakdown of the findTopDensityCubes function:
Initialize Counts Array: The function initializes a 3D array counts to store the count of colors
in each cube. The size of the array is determined by the cubeSize and the bounds of the 3D
color space.
Count Colors in Each Cube: The function iterates over the colors array and increments the
count in the corresponding cube. The cube index is calculated using the Math.floor function to
divide the color value by the cubeSize.
Create Indices and Counts Array: The function creates an array of objects, where each object
contains the index of a cube and its count.
Sort and Slice: The function sorts the array in descending order of count and returns the top n
indices, where n is a parameter (default value is 12).
24
COLORSCOPE
EyeDropper API:
25
COLORSCOPE
This script is using the EyeDropper API to allow the user to pick a color from the screen. Here's
a breakdown of what the script does:
Add event listener to "Start" button: When the "Start" button is clicked, the script opens the
EyeDropper API, which allows the user to select a color from the screen.
Get color value from EyeDropper: Once the user selects a color, the script gets the color
value in hexadecimal format using colorValue.sRGBHex.
Convert hex to RGB: The script converts the hex value to an RGB array using a loop that
extracts the red, green, and blue components from the hex string.
Display color information: The script displays the hex and RGB values in input fields (hex-
val-ref and rgb-val-ref) and sets the background color of an element (picked-color-ref) to the
selected color.
Add event listener to image: The script adds an event listener to an image element (myImage)
that listens for mousemove events.
Get color at mouse position: When the user moves the mouse over the image, the script gets
the color at the mouse position using the getImageData method of a canvas element. It extracts
the RGB values from the pixel data and displays them in a text element (color-info).
Set background color of color-info element: The script sets the background color of the color-
info element to the color at the mouse position.
Note that the script uses the EyeDropper API, which is a relatively new API that allows web
applications to access the user's screen and select colors. This API is not supported in older
browsers, so you may need to add polyfills or fallbacks for older browsers.
This code generates a random color and creates a linear gradient using two colors. Here's a
breakdown of what the code does:
26
COLORSCOPE
➢ getRandomColor() function
Generates a random hexadecimal color code using Math.random() and toString(16).
The 0xffffff value is the maximum possible value for a hexadecimal color code (FFFFFF in
hex).
The resulting random color code is prefixed with a # symbol to create a valid hexadecimal
color string (e.g., #5665E9).
➢ generateGradient(isRandom) function
If isRandom is true, the function updates the values of two color input fields (colorInputs[0]
and colorInputs[1]) with random colors generated by the getRandomColor() function.
Creates a linear gradient string using the values of:
selectMenu.value: the direction of the gradient (e.g., "to bottom", "to right", etc.).
colorInputs[0].value and colorInputs[1].value: the two colors that make up the gradient.
The gradient string is in the format linear-gradient(direction, color1, color2).
The function applies the generated gradient to:
gradientBox: an HTML element that displays the gradient.
document.body: sets the background of the entire page to the generated gradient.
textarea: sets the value of a textarea element to the generated gradient string, which can be used
to copy and paste the CSS code.
Example calculation
Let's say we want tints and shades of Rebecca Purple, #663399.
10% tint
#663399 is converted to the RGB equivalent of 102, 51, 153
R: 102 + ((255 - 102) x .1) = 117.3, rounded to 117
G: 51 + ((255 - 51) x .1) = 71.4, rounded to 71
B: 153 + ((255 - 153) x .1) = 163.2, rounded to 163
27
COLORSCOPE
28
COLORSCOPE
CHAPTER 9 : SNAPSHOTS
29
COLORSCOPE
30
COLORSCOPE
31
COLORSCOPE
32
COLORSCOPE
33
COLORSCOPE
The project utilized HTML, CSS, and JavaScript to implement these features. The development
process involved:
Setting Up the Project Environment: Using XAMPP to host the project locally and managing
files in a structured directory.
Creating the User Interface: Designing and developing the HTML structure and CSS styling
for a user-friendly interface.
Implementing Core Functionality: Writing JavaScript code to handle user interactions and
generate dynamic content based on user inputs.
Storing Data: For the "Contact Us" form, PHP and MySQL were used to store user-submitted
data securely in a database.
Testing and Debugging: Ensuring cross-browser compatibility, responsive design, and the
proper functioning of all features through extensive testing.
9.2 Conclusion:
The Color Detection Website successfully met its objectives, providing users with a powerful
toolset for exploring and manipulating colors. Key outcomes include:
34
COLORSCOPE
Enhanced User Experience: The intuitive interface and real-time interactivity significantly
improved the user experience, making color selection and manipulation straightforward.
Versatile Functionality: The range of features catered to various needs, from basic color code
generation to advanced gradient and palette creation, offering versatility to designers and
developers.
Future Enhancements: While the current implementation provides robust functionality,
several areas for future enhancement were identified:
➢ Advanced Color Theory Algorithms: Implementing more sophisticated algorithms
for palette generation to include additional color harmony rules.
➢ User Customization Options: Allowing users to save, share, and export their
generated palettes, gradients, and tints.
➢ Improved UI/UX: Enhancing the user interface with animations, transitions, and a
more modern design to further improve user engagement.
➢ Additional Tools: Expanding the toolset to include features like shade generation, color
blindness simulation, and contrast checking.
The Color Detection Website project demonstrates the effective use of web technologies to
create a practical and engaging application. The successful implementation of various color-
related features underscores the potential of JavaScript, HTML, and CSS in building interactive
web applications. With further enhancements, this project can evolve into an even more
powerful tool for designers, developers, and anyone interested in exploring the world of colors.
35
COLORSCOPE
https://www.geeksforgeeks.org/software-development-life-cycle-sdlc/
https://www.geeksforgeeks.org/html-introduction/
https://developer.mozilla.org/en-US/docs/Web/CSS
https://en.wikipedia.org/wiki/JavaScript
https://www.howtogeek.com/761277/what-is-a-hex-code-for-colors/
https://www.w3schools.com/html/html5_canvas.asp
https://jquery.com/
https://www.w3schools.com/jquery/jquery_get_started.asp
https://clipboardjs.com/
36