Total Pageviews

Wednesday, September 2, 2026

📊 Histogram Specification / Matching

Match the histogram of an input image with a target image
Upload an input image and a target image.

1. Input Image

2. Target Image

3. Input Histogram

4. Target Histogram

5. Input CDF

6. Target CDF

7. Gray-Level Mapping

Input Gray Input H Input CDF Target Gray Target CDF New Map

8. New Mapped Image

9. Histogram After Mapping

10. Mapping Result

Waiting for histogram matching...

🧮 Histogram Matching Mathematics

Step 1 — Convert image to grayscale

For an RGB pixel:

Gray = 0.299R + 0.587G + 0.114B
Step 2 — Calculate histogram

For each gray level rk, count the number of pixels.

H(rk) = nk
Step 3 — Calculate probability

If N is the total number of pixels:

P(rk) = nk / N
Step 4 — Calculate input CDF
Cinput(rk) = Σ P(rj)

where j = 0 to k.

Step 5 — Calculate target CDF
Ctarget(zq) = Σ P(zj)
Step 6 — Find the matching gray level

For every input gray level, find the target gray level whose CDF is closest to the input CDF.

Find z such that Ctarget(z) ≈ Cinput(r)
Step 7 — Create the mapping
r → z

Every pixel having gray level r is replaced with the mapped gray level z.

Example
Input CDF = 0.60

Suppose the target histogram has:

Target CDF at gray 150 = 0.58 Target CDF at gray 151 = 0.61

The closest target CDF is 0.61, therefore:

Input gray level → Target gray level r → 151
Complete process
Input Image → Grayscale → Input Histogram → Input CDF → Target Histogram → Target CDF → Mapping → New Image

Histogram Equalization Visualizer

📊 Histogram Equalization Visualizer

Upload an image and explore grayscale conversion, histogram analysis, histogram equalization and its mathematics.
Please upload an image to begin.

1. Original Image

2. Grayscale Image

3. Grayscale Histogram

4. Histogram Values

Gray Level Frequency Probability CDF New Gray Level

5. Equalized Image

6. Histogram After Equalization

🧮 Histogram Equalization Mathematics

Step 1: Find the frequency

For every grayscale intensity rk, count how many pixels have that intensity.

nk = Number of pixels having intensity rk
Step 2: Calculate probability

Let n be the total number of pixels.

p(rk) = nk / n
Step 3: Calculate cumulative distribution function (CDF)
CDF(rk) = Σ p(rj)    for j = 0 to k

The CDF adds the probabilities from the first gray level up to the current gray level.

Step 4: Histogram equalization formula
sk = (L - 1) × CDF(rk)

Where:

  • L = number of possible gray levels
  • For an 8-bit image, L = 256
  • Therefore L − 1 = 255
  • rk = original gray level
  • sk = new equalized gray level
Step 5: Example calculation

Suppose an intensity level has:

CDF = 0.60

For an 8-bit image:

s = 255 × 0.60
s = 153

Therefore, the original gray level is mapped to approximately gray level 153.

Complete process
Image → Grayscale → Histogram → Probability → CDF → Mapping → Equalized Image

Monday, August 31, 2026

➕ ARRAY INSERTION AT FRONT

➕ ARRAY INSERTION AT FRONT
Insert a new value at index 0 by shifting every existing element one position to the RIGHT

📥 Enter Array and New Value

🎬 Step-by-Step Animation

Enter an array and a new value, then press START INSERTION.

📊 Operation Statistics

Array Size 0
Shifts Completed 0

📝 Step-by-Step Explanation

🧮 Mathematical Representation

Suppose:
A = [10, 20, 30, 40, 50]

New value:
5

To insert at the FRONT, all existing elements must move one position RIGHT.

A[5] ← A[4]

50 moves from index 4 to index 5.

A[4] ← A[3]

40 moves from index 3 to index 4.

A[3] ← A[2]

30 moves from index 2 to index 3.

A[2] ← A[1]

20 moves from index 1 to index 2.

A[1] ← A[0]

10 moves from index 0 to index 1.

Finally:
A[0] = 5

Final Array:
[5, 10, 20, 30, 40, 50]

💻 Algorithm

INSERT_FRONT(A,n,value)

Step 1: Start from the last element.

Step 2: Move each element one position RIGHT.

For: i = n − 1 down to 0

Perform: A[i + 1] = A[i]

Step 3: A[0] = value

Step 4: n = n + 1

⏱️ Time and Space Complexity

Time Complexity O(n)
Number of Shifts n

🎯 Final Result

Result will appear here.

🗑️ ARRAY DELETION AT FRONT

🗑️ ARRAY DELETION AT FRONT
Delete the first element and shift every remaining element one position to the LEFT

📥 Enter Array Values

🎬 Step-by-Step Animation

Enter values and press START DELETE.

📊 Operation Statistics

Array Size 0
Shifts Completed 0

📝 Step-by-Step Explanation

🧮 Mathematical Representation

Original Array
A = [10, 20, 30, 40, 50]

First element is deleted:
DELETE A[0]

Deleted value:
10

Now shift the remaining elements LEFT:

A[0] ← A[1]

20 moves from index 1 to index 0.

A[1] ← A[2]

30 moves from index 2 to index 1.

A[2] ← A[3]

40 moves from index 3 to index 2.

A[3] ← A[4]

50 moves from index 4 to index 3.

Finally:
n = n − 1

Therefore:
[20, 30, 40, 50]

💻 Algorithm

DELETE_FRONT(A,n)

Step 1: Delete the first element.

Step 2: Start from the second element.

Step 3: Move each element one position LEFT.

For: i = 1 to n − 1

Perform: A[i − 1] = A[i]

Step 4: n = n − 1

⏱️ Time and Space Complexity

Time Complexity O(n)
Number of Shifts n − 1

🎯 Final Result

Result will appear here.

⚡ QUICK SORT VISUALIZER

```
⚡ QUICK SORT VISUALIZER
Choose Pivot • Partition • Compare • Swap • Recursively Sort
```
```

📥 Enter Your Data

```
```

📊 Current Array

Enter values and press START QUICK SORT.
```
```

📈 Live Statistics

Recursion Level 0
Comparisons 0
Swaps 0
Partitions 0
Steps 0
```
```

🔀 Partition Visualization

```
```

📝 Step-by-Step Explanation

1
Quick Sort selects a pivot and rearranges the elements so that smaller values go to the left and larger values go to the right.
```
```

🧮 Quick Sort Mathematics

Choose a pivot:
pivot = A[high]

Start:
i = low − 1

For every element A[j]:
If A[j] ≤ pivot
then:
i = i + 1
and swap:
A[i] ↔ A[j]

Finally:
A[i+1] ↔ A[high]

The pivot is now in its correct position.
```
```

🔢 Complete Mathematical Example

Initial Array:
10, 7, 8, 9, 1, 5

Choose last element as pivot:
pivot = 5

Start:
i = −1

Compare 10 with 5:
10 ≤ 5 → False
No swap.

Compare 7 with 5:
7 ≤ 5 → False
No swap.

Compare 8 with 5:
8 ≤ 5 → False
No swap.

Compare 9 with 5:
9 ≤ 5 → False
No swap.

Compare 1 with 5:
1 ≤ 5 → True
i = 0
Swap A[0] and A[4]:
1, 7, 8, 9, 10, 5

Finally swap pivot 5 with A[1]:
1, 5, 8, 9, 10, 7

Pivot 5 is now in its final position.

Left partition:
[1]

Right partition:
[8,9,10,7]

Quick Sort recursively processes both partitions.
```
```

⚙️ How Quick Sort Works

1
Choose a Pivot: Select one element as the pivot. This visualizer uses the last element.
2
Partition: Move elements smaller than or equal to the pivot toward the left side.
3
Move larger elements toward the right side.
4
Place the pivot between the two partitions.
5
Recursively apply Quick Sort to the left partition.
6
Recursively apply Quick Sort to the right partition.
```
```

⚖️ Advantages & Disadvantages

+
Advantages
• Very fast on average.
• Average time complexity is O(n log n).
• Can be implemented in-place.
• Usually performs well in practical applications.
Disadvantages
• Poor pivot selection can produce O(n²) time.
• Standard Quick Sort is not stable.
• Recursive implementation requires stack space.
```
```

⏱️ Time & Space Complexity

Best Case O(n log n)
Average Case O(n log n)
Worst Case O(n²)
Average Space O(log n)
```
```

🎯 Pivot Concept

A good pivot divides the array into two approximately equal parts.

Example:
[2, 4, 5] | 6 | [7, 8, 9]

This produces approximately balanced partitions and gives:
O(n log n) average performance.

A poor pivot may produce:
[] | 1 | [2,3,4,5,6,7]

Repeated poor partitions can lead to:
O(n²)
```