MATLAB Answers


identify valid and invalid image

Asked by Elysi Cochin on 5 Jan 2013

i execute a code and get two types of output.... one is valid and the other is invalid.... the valid output image has content content in it.... whereas the invalid image is totally black....

based on this information what can i do to display a message that the image is valid or invalid.... some condition check so that i can display the message correctly.... please can someone reply.....


1 Answer

Answer by Walter Roberson
on 5 Jan 2013
 Accepted answer

if ~any(TheOutputImage(:))
  msgdlg('Outside of a dog, a book is man''s best friend. Inside of a dog, it is too dark to read.');


The first thing you need to do is stop using "image" as a variable name: doing so makes it difficult to use the function image()

Second, if your code is not giving you the message box, then the output is not "totally black" as you claimed. Find out what


are for the invalid images.

sir i got it... thank u sir... i wrote the display outside the for also... thank u sir...

Put a breakpoint in at the "if ~any" and run your code again with something that creates an invalid image. Single-step through the code. I think you will find that the black image is not displayed by this section of code. If you continue single-stepping you will find the place that is displaying it.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!