showing error why?morphological hit and miss operation

조회 수: 2 (최근 30일)
muzafar
muzafar 2012년 10월 20일
댓글: Torkan 2019년 10월 14일
clc;
clear all;
close all;
bw=imread('hm.png');%reading image 1
figure;
imshow(bw);title('Original Image1 of dilation');%displaying original image
se1=strel([0 0 0;0 1 1;0 1 0]);
se2=strel([1 1 1;1 0 0;1 0 0]);
bw2=bwhitmiss(bw,se1,se2);
figure;
imshow(bw2);
title('after hit and miss operation');%displaying original image 2
error is.........
Error using imageDisplayValidateParams>validateCData (line 121)
If input is logical (binary), it must be two-dimensional.
Error in imageDisplayValidateParams (line 31)
common_args.CData = validateCData(common_args.CData,image_type);
Error in imageDisplayParseInputs (line 79)
common_args = imageDisplayValidateParams(common_args);
Error in imshow (line 198)
[common_args,specific_args] = ...
Error in hitmiss3 (line 11)
imshow(bw2);

답변 (2개)

Matt J
Matt J 2012년 10월 20일
Your bw is not class logical. Check "class(bw)" or "whos bw"

Walter Roberson
Walter Roberson 2016년 11월 14일
You have
bw=imread('hm.png');%reading image 1
and that is reading in an RGB image, which is a numeric array of dimension 3. That is supported by bwhitmiss, creating a binary (logical) 3D array.
imshow() does not know how to display 3D arrays of class logical.
If you want to use the binary values as indicating that the respective color channel is fully on or fully off, then
imshow( double(bw2) )
If you had thought the image was not RGB, then keep in mind that RGB images can look gray. png files are typically RGB, but sometimes are grayscale.
(jpg files on the other hand, are rarely stored as grayscale in my experience; I have only encountered perhaps two such files. So a jpg file is very likely an RGB file even if the image looks gray.)
  댓글 수: 1
Torkan
Torkan 2019년 10월 14일
So, Walter,
Even if we change the format of the file, this is not going to work right?

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

Community Treasure Hunt

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

Start Hunting!

Translated by