R Programming File
R Programming File
This laboratory
experiment provides for thresholding an image and the evaluation of its histogram.
Histogram equalization. This experiment illustrates the relationship among the
intensities (gray levels) of an image and its histogram.
# Program:
# Load an image
img <- load.image("path/to/your/image.jpg")
# Compute histograms
hist_original <- hist(as.vector(as.matrix(gray_img)), breaks = seq(0, 1, by = 1/256),
plot = FALSE)
hist_equalized <- hist(as.vector(as.matrix(equalized_img)), breaks = seq(0, 1, by =
1/256), plot = FALSE)
ggplot() +
geom_line(aes(x = hist_equalized$mids, y = hist_equalized$counts), color = "blue") +
labs(title = "Equalized Image Histogram") +
theme_minimal()
# Program:
library(imager)
library(ggplot2)
# Load an image
image <- load.image('path/to/your/image.jpg')
# Rotation
rotation_matrix <- matrix(c(cos(pi/4), -sin(pi/4), sin(pi/4), cos(pi/4)), nrow = 2)
rotated_image <- imager::rotate(image, matrix = rotation_matrix)
# Scaling
scaling_factor <- 1.5
scaled_image <- resize(image, scale = scaling_factor)
# Translation
translation_matrix <- matrix(c(1, 0, 50, 0, 1, 30), nrow = 2)
translated_image <- translate(image, matrix = translation_matrix)
# Load an image
image <- load.image('path/to/your/image.jpg')
# Program:
library(imager)
library(ggplot2)
# Load an image
image <- load.image('path/to/your/image.jpg')
# Load an image
image <- load.image('path/to/your/image.jpg')
# Program:
library(imager)
library(ggplot2)
# Load an image
image <- load.image('path/to/your/image.jpg')
# Load an image
image <- load.image('path/to/your/image.jpg')