From: Maxx Chatsko on
Hello all,
Background:
I have a program that gets spectral data from a number of images in a folder. The user inputs a number of spectra they wish to see and the program displays a plot of the spectra. Each spectra represents one region of interest (ROI), which is the average spectral data from a number of rows in the image data array retrieved from imread and other image processing toolboxes.
I need the ROIs to all be the same size so they are comparable so the program gets the maximum number of ROIs possible and only takes what it needs.

Example:
So, if a user wants 17 spectra, the program does the following math:
nspec=17; numfi=5 %(number of images)
nspec_div = fix(nspec/numfi)+1
= 4
%Total ROIs across all images (5*4)
numfi*nspec_div = 20;

%images that only use 3 of their 4 ROIs
rmndr=((numfi*nspec_div)-nspec); % 20-17
= 3
%Determine how many images will have all ROIs included
numfull=numfi-rmndr;
=2
There are 5 images being processed and I only need 17 ROIs from a total of 20 ROIs (each image has 4 ROIs). Therefore, 3 images will give me 3 ROIs and 2 images will give me 4 ROIs, for a total of 17.

Question:
I have all of the spectral data in an all_arr (20xWL). I need to move the data to another super (17xWL) while skipping the fourth, 8th, and 12th rows. This is broken into two parts:

nspec_lo=nspec_div-1; %this is fine, need it elsewhere, not the problem =3 here

%Images that have 3 ROIs represented
c=0;
for c=1:rmndr
cmin=nspec_lo*c-nspec_lo+1;
cmax=nspec_lo*c;

%Skip one row for each rmndr
super(cmin:cmax,:)=all_arr(???????????)
end

%Images with all 4 ROIs represented
d=0;
for d=1:numfull
dmin=cmax+(nspec_div*d-nspec_div+1);
dmax=cmax+(nspec_div*d);
super(dmin:dmax,:)=all_arr(dmin:dmax,:)
end

I need to skip the rows specified above. Please do not simply write the numbers 4, 8, and 12 into the code if you are trying to help because these numbers only work for this example.
Thanks
Maxx

From: dpb on
Maxx Chatsko wrote:
....

> I need to skip the rows specified above. Please do not simply write the
> numbers 4, 8, and 12 into the code if you are trying to help because
> these numbers only work for this example...

I couldn't parse what you were really trying to say but seems to me if
you have 5 images from which to select seventeen pieces of sequentially
the determination of which image to choose from (hence the array slice
if I ken the question) would be something like...

> for idx=0:16, disp(['image ' num2str(mod(idx,5)+1)]),end
image 1
image 2
image 3
image 4
image 5
image 1
image 2
image 3
image 4
image 5
image 1
image 2
image 3
image 4
image 5
image 1
image 2
>>

--