필터 지우기
필터 지우기

Given an image , how to efficiently (vectorization) make all the elements to zero except the one with information?

조회 수: 1 (최근 30일)
The image is scaled color version of absolute value of the matrix.

채택된 답변

Image Analyst
Image Analyst 2018년 8월 28일
This will do it:
clc; % Clear the command window.
clearvars;
close all; % Close all figures (except those of imtool.)
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;fontSize = 22;
s = load('image_data.mat')
D = s.D;
realD = abs(real(D));
imagD = abs(imag(D));
subplot(2, 3, 1);
imshow(realD, []);
axis square
title('Real Image', 'FontSize', fontSize);
impixelinfo();
subplot(2, 3, 2);
histogram(realD);
grid on;
title('Histogram of Real Image', 'FontSize', fontSize);
subplot(2, 3, 4);
imshow(imagD, []);
axis square
title('Imaginary Image', 'FontSize', fontSize);
impixelinfo();
subplot(2, 3, 5);
histogram(imagD);
grid on;
title('Histogram of Imaginary Image', 'FontSize', fontSize);
backgroundValueR = 5e8;
backgroundValueI = 3e8;
binaryImageR = realD > backgroundValueR;
binaryImageI = imagD > backgroundValueI;
subplot(2, 3, 3);
imshow(binaryImageR, []);
axis square
impixelinfo();
title('Real Image, binarized', 'FontSize', fontSize);
subplot(2, 3, 6);
imshow(binaryImageI, []);
axis square
impixelinfo();
title('Imaginary Image, binarized', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
% Apply the mask
% Mask the image using bsxfun() function to multiply the mask by each channel individually.
maskedRealImage = bsxfun(@times, realD, cast(binaryImageR, 'like', realD));
maskedImagImage = bsxfun(@times, imagD, cast(binaryImageI, 'like', imagD));
figure;
subplot(2, 1, 1);
imshow(maskedRealImage, []);
axis square
impixelinfo();
title('Masked Real Image, binarized', 'FontSize', fontSize);
subplot(2, 1, 2);
imshow(maskedImagImage, []);
axis square
impixelinfo();
title('Masked Imaginary Image, binarized', 'FontSize', fontSize);
  댓글 수: 9
Image Analyst
Image Analyst 2018년 8월 29일
I gave two comments above telling you how to do that. You inspect the histogram. It's a judgement call - there are lots of values you could use so just decide where in the histogram you want to threshold it.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2018년 8월 26일
Probably thresholding and masking.
mask = theImage ~= backgroundValue; % Threshold.
theImage(mask) = 0; % Mask
Attach your data in a .mat file if you want more help.

Community Treasure Hunt

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

Start Hunting!

Translated by