두 이미지, 그레이 스케일 이미지 및 RGB
이미지를 조작하려면 다음 MATLAB 코드가 필요합니다. 요점은 두 이미지 모두에 Average
, Gaussian
및 Laplacian
필터를 적용하는 것입니다.RGB 이미지에 Matlab 이미지 필터 적용
%%Clear
clear
clc
%%Reading images
gray=imread('cameraman.tif')
[gray_table gray_map]=gray2ind(gray,256)
rgb=imread('peppers.png')
[rgb_table rgb_map]=rgb2ind(rgb,256)
%%Creating filters
average=fspecial('average',3)
gaussian=fspecial('gaussian',3,0.5)
laplacian=fspecial('laplacian',0.9)
%%Applying filters
average_filterd_gray_table=imfilter(gray_table,average)
gaussian_filterd_gray_table=imfilter(gray_table,gaussian)
laplacian_filterd_gray_table=imfilter(gray_table,laplacian)
average_filterd_rgb_table=imfilter(rgb_table,average)
gaussian_filterd_rgb_table=imfilter(rgb_table,gaussian)
laplacian_filterd_rgb_table=imfilter(rgb_table,laplacian)
%%view
figure
subplot(1,4,1),imshow(gray_table,gray_map),title('Original Indexed Gray')
subplot(1,4,2),imshow(average_filterd_gray_table,gray_map),title('Average Filtered Indexed Gray')
subplot(1,4,3),imshow(gaussian_filterd_gray_table,gray_map),title('Gaussian Filtered Indexed Gray')
subplot(1,4,4),imshow(laplacian_filterd_gray_table,gray_map),title('Laplacian Filtered Indexed Gray')
figure
subplot(1,4,1),imshow(rgb_table,rgb_map),title('Original Indexed RGB')
subplot(1,4,2),imshow(average_filterd_rgb_table,rgb_map),title('Average Filtered Indexed RGB')
subplot(1,4,3),imshow(gaussian_filterd_rgb_table,rgb_map),title('Gaussian Filtered Indexed RGB')
subplot(1,4,4),imshow(laplacian_filterd_rgb_table,rgb_map),title('Laplacian Filtered Indexed RGB')
회색조 이미지의 경우 코드가 올바르게 작동합니다. 그러나 RGB 이미지에서는 왜곡 된 결과 만 나타납니다. 그것을 고치는 방법?
필터를 각 채널에 개별적으로 적용 해 보셨습니까? 아니면 각 HSV 채널에 별도로? 아니면 그냥 HSV의 "V"채널 – Dan
@ 단 당신은 그것을 코드하시기 바랍니다 수 있을까요? – HussainBiedouh
제안 된 답변 중 어떤 것도 도움이 되었습니까? 그렇다면 하나를 받아 들여서 스레드를 닫으십시오. –