Mega Search
23.2 Million


Sign Up

Make a donation  
read specific pixel value on an image  
News Group: comp.soft-sys.matlab

Hello,
Could you please help me in reading pixel value for a specific area on images. I have this code written by a friend to read and plot pixel values for a serious of images. Now I am interested in a very small spot on these images and I just want to modify the codes to read and plot the pixel value for that area only (i=450 to 500 and j=450 to 500). 

Any helps will be appreciated.

loc_data='C:\Users\Desktop\Images\';
loc_figs='C:\Users\Desktop\figures\';

fnames=ls([loc_data '*.tif'])

for ii=1:length(fnames(:,1))
    clear temp
    data(:,:,ii)=imread([loc_data fnames(ii,:)]);
    
%     figure(1);clf;hold on;
%     imagesc(data(:,:,ii))
%     axis xy image
%     caxis([0 255])
%     colorbar
%     se=size(data(:,:,ii))
%     title([fnames(ii,:)])
%     pause(0.5)
end

for ii=1:length(data(:,1,1))
    for jj=1:length(data(1,:,1))
        medval(ii,jj)=median(data(ii,jj,:));
        modeval(ii,jj)=mode(data(ii,jj,:));
        
        figure(3);clf;hold on;
        plot(squeeze(data(ii,jj,:)))
        plot([1 length(data(1,1,:))],[medval(ii,jj) medval(ii,jj)],'--k')
        plot([1 length(data(1,1,:))],[modeval(ii,jj) modeval(ii,jj)],'--r')
        title(['ii=' int2str(ii) ', jj=' int2str(jj)])
        ylim([0 255])
        xlim([1 length(data(1,1,:))])
        legend('Pixel Value','Median','Mode','location','southeast')
        legend('boxoff')
        saveas(gcf,[loc_figs 'II_' int2str(ii) '_JJ_' int2str(jj)],'tif') 
    end
end

figure(2);clf;hold on
imagesc(medval)
axis xy image

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 29-Aug-2016, at 4:44 PM EST
From: Muhammed Mustafa