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

New to MATLAB?

Thread Subject:
impixel problem

Subject: impixel problem

From: Aron Sceidt

Date: 11 Apr, 2011 09:17:05

Message: 1 of 1

I am displaying two images using subplotting. Right after I am calling impixel in a loop. Now the problem is that if the user in the first iteration selects values from the image that was first plotted (image1) I get the first row with NaN:

colors =

   NaN NaN NaN
   251 252 247

On the other hand if i select all the values from the second image that was plotted I get correct values. Now I want the user to have the ability to select from any of the two images (depending on what he seems good). Is there a solution to my problem?

The code I'm using is the following:

noOfClusters = 2;

image1 = imread('trees.tif');
image2 = imread('board.tif');

tmpfig=figure('numbertitle','off','name','Cluster RGB Image','visible','off');
subplot(1,2,1), imshow(image1);
subplot(1,2,2), imshow(image2);
set(tmpfig,'units','pixels','position',[0 0 1000 800]);
% Prompt for target cluster colors
colors = zeros(noOfClusters,3);
for ii=1:noOfClusters
    title(sprintf('Select sample pixel(s) in cluster %d of %d',ii,noOfClusters));
    tmp = impixel;
    colors(ii,:) = mean(tmp,1);

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us