Encoder-Decoder Model for Grayscale to RGB Conversion

버전 1.0.0 (6.42 KB) 작성자: Michael Alvarez
This script demonstrates creating and training an encoder-decoder model using random overlapping image patches.
다운로드 수: 5
업데이트 날짜: 2024/5/29

라이선스 보기

This script demonstrates how to create random overlapping patches of an image to train an encoder-decoder model that converts grayscale images to RGB images.
Some steps:
  • reading an example image (`peppers.png`)
  • call the function `image2patch_randperm_overlap` wiht the parameter
clc
clear
close all force
X = imread('peppers.png') ;
figure, imagesc(X), title('Example')
imageOut = mat2gray( X ) ;
imageIn = rgb2gray( imageOut ) ;
deltaX = 32 ;
deltaY = 32 ;
overlap = 8 ;
per = .8 ; % percent to train
seed = 1 ; % to control the random numbers
make_plot = 1 ;
[patchs] = image2patch_randperm_overlap( ...
imageIn , imageOut , deltaX , deltaY , overlap , seed , per , make_plot) ;
  • to visualizate the Train and Test data:
  • Encoder-Decoder Model: created using the Deep Neural Network designer
net = trainNetwork(patchs.train.In,patchs.train.Out,lgraph,options);
  • Computing the SSIM value (in average for the patchs) to get an idea of how well is the adjusted the model:
% SSIM_Training_Data = 0.8577
% SSIM_Testing_Data = 0.7857
  • Testing on the whole image (including the training patches):
  • Testing on a different Image (`cameraman.tif`):
Key Functions and Parameters
- **image2patch_randperm_overlap**: Generates random overlapping patches from the input images.
- **layer_Encoder_Decoder**: Script that defines the encoder-decoder network architecture.
- **trainingOptions**: Configures the training options for the network.
- **trainNetwork**: Trains the neural network.
- **mean_ssim**: Calculates the mean SSIM between predicted and actual images (for 4D matrices).
- **image2patch_overlap**: Converts an image into overlapping patches.
- **patch_overlap2image**: Converts patches back into a full image.
Conclusion
This script effectively demonstrates the process of creating and training an encoder-decoder model using random image patches and testing the model on both the training image and a new test image. The use of overlapping patches helps in reconstructing the full image during the prediction stage. This approach exemplifies how a deep learning model can be trained for the challenging task of converting grayscale images to RGB using a single image without repeating patches.
Author: Michael Alvarez
Email: michael.alvarez2@upr.edu

인용 양식

Michael Alvarez (2024). Encoder-Decoder Model for Grayscale to RGB Conversion (https://www.mathworks.com/matlabcentral/fileexchange/167061-encoder-decoder-model-for-grayscale-to-rgb-conversion), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2020b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0