필터 지우기
필터 지우기

Why is my image appearing all white? I am trying to detect its edges with the following code..

조회 수: 14 (최근 30일)
clc;
clf;
i=imread('AB_1-16_pH_7.jpg');
subplot(421);
imshow(i);
title('orginalimage');
j=rgb2gray(i);
subplot(422);
imshow(j);
title('grayimage');
subplot(423);
m=edge(j,'canny');
imshow(11);
title('edge with canny function');
subplot(424);
figure(2)
m=imread('AB_1-16_pH_7.jpg');
imshow(m);
title('base image');

채택된 답변

Image Analyst
Image Analyst 2014년 10월 7일
Because you don't show the edge image. You're displaying 11 (eleven).
Here, try this improved code:
% Boilerplate initialization stuff
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
% Read in original RGB image.
filename = 'peppers.png'
rgbImage = imread(filename);
subplot(2,2,1);
imshow(rgbImage);
title('Original Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Convert to grayscale.
grayImage=rgb2gray(rgbImage);
subplot(2,2,2);
imshow(grayImage);
title('Gray Scale Image', 'FontSize', fontSize);
% Get edge image.
edgeImage = edge(grayImage, 'canny');
subplot(2,2,3);
imshow(edgeImage, []);
title('Edge Image with Canny function', 'FontSize', fontSize);

추가 답변 (1개)

Neo
Neo 2014년 10월 20일
Thank you for answering my question. I am a beginning coder, I was wondering what resources would you recommend so that I can read up on how to advance my coding because some of the coding that you used is foreign to me, such as format long g; format compact; and % Enlarge figure to full screen. set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]); Where can I learn? I have read a few chapters from a digital processing textbook but it is not sufficient to enable me to write the code I want. Thanks, Neo.
  댓글 수: 1
Image Analyst
Image Analyst 2014년 10월 20일
For individual commands, look them up in the help. In general, to learn MATLAB, see this link: http://www.mathworks.com/matlabcentral/answers/8026-best-way-s-to-master-matlab.
It looks like my code does a Canny edge and it's not all white so it looks like I solved your problem, so if you wouldn't mind officially "Accepting" my answer, I'd appreciate it.

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

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by