showing error why?morphological hit and miss operation

1 vue (au cours des 30 derniers jours)
muzafar
muzafar le 20 Oct 2012
Commenté : Torkan le 14 Oct 2019
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);
  1 commentaire
Matt J
Matt J le 20 Oct 2012
Please mark up your code so we can read it.

Connectez-vous pour commenter.

Réponses (2)

Matt J
Matt J le 20 Oct 2012
Your bw is not class logical. Check "class(bw)" or "whos bw"

Walter Roberson
Walter Roberson le 14 Nov 2016
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 commentaire
Torkan
Torkan le 14 Oct 2019
So, Walter,
Even if we change the format of the file, this is not going to work right?

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by