LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array manupulation

Solved!
Go to solution
I have an 1d array of 1500000(15 lakh) values(index).It has random values of 255.I need to place all the 255s at the multiples of 1500.Suppose in the input array i get 255 at 500th index and the 2nd at 1000th idex.I need to put the first 255 at 1st index and 2nd 255 at 1501 and replace the gap with 200.Please help
Message 1 of 42
(4,864 Views)
Hi muks,

why don't you stay in your original thread? The goal has slightly changed, but you still work with the same data...

What will happen to the values at "1st index" and "1501 index"? Will they be overwritten? Do you want to swap values? Do you want to increase the array size?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 42
(4,857 Views)
I want to increase the array size.First 255 no matter where it occurs is my first pixel of my output array.The second 255 has to be placed at 1501th index.If another 255 occurs before 1501 then also i need to place that 255 at 1501 only and i need to fill a value of 100 to make up the difference.Hope i am clear.
 
The reason for starting a new thread is to add clarity.I thought the image was a bit confusing.

Message 3 of 42
(4,850 Views)
Hi muks,

"Hope i am clear" - not at all...

What happens with the 1st "255", when you move the next "255" to the same place? Overwrite it?

Increasing array sizes is always "troublesome": You always create new copies - in your case moving blocks of 1.5MB in memory...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 42
(4,846 Views)

eg

Input                                                               output   

(index) (value)                                              index     value                              

1             20                                                     1           255

2             50                                                      2            20

3             75                                                     .  

.                                                                        .

.                                                                        .

.                                                    (1199-500)  699       45

500    255                                                         700       200

501       20                                                       701        200

.                                                                          .

.                                                                          .

.                                                                          .

.

.                                                                        1501            255

.                                                                         1502             34

1199      45

1200     255

1201      34



Message Edited by muks on 06-19-2008 06:08 AM
Message 5 of 42
(4,842 Views)
Hi muks,

what happens with that "255" at input-index 500? Will it be deleted?
What happens with values at index 501-1198? Where do they end up? You seem to overwrite them starting from output-index 699?
Why do you move input-index 1199 back to 699?

Nothing clear to me, I don't realize a clear scheme/pattern to do all those data moving/copying... Without a scheme I can't propose a routine to work with...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 42
(4,825 Views)
I will eloborate a little bit.I am getting a stream of data which is in encrypted form.So at the instance i am capturing the data would have shifted and hence the image will be distorted.
 
Now the 255 you see in the image is being sent as the line reference.imagine a 1500x1000 image.Now each 255 u see should be placed as the first element of each row.So lets consider the ideal case.I get the input starting from 255 .I get the next 255 at 1501th index and so on for 1000 times.Now consider the real time situation.255 occurs anywhere and now i need to put this 255 as my first value in the output.Again i am getting the next 255 also randomly.I need to put the 255 at multiples of 1500s no matter where the 255 occurs.I am not over writing anything,
 
To answer your question consider that 255 occurs at 100,200 and 300th index of the array.Now my output array will be filled as follows.
 
output arrays 0 to 100 = input arrays 100 to 200
100 to 1500                = 200 (i am not over writing anything)
1501 to 1602              = input arrays 200 to 300(since i encounter the subsequent 255s at 200 and 300 also please note that i am not overwriting anything neither am i missing anything)
1602 to 3000               =  200

 
Message 7 of 42
(4,819 Views)

Hi Muks.

Could You please upload an image of what You're supposed to end up with. (Like Ben already asked for in one of Your many other Threads)

For Your example above:

What happens to the values from index 0-99 in Your input array?? Are they discarded?

For the picture (PNG) You uploaded:

When scanning through the resulting 1D-array, i found 4132 entries containing "255". This would mean 4132 lines, which again means that the picture would be another size than 1500x1000 pixels. Actually 4132x1500 pixels. Is that correct?

Note: Please answer the questions You are asked instead of starting a new Thread.

 



Message Edited by BCL@Servodan on 06-19-2008 10:28 AM
Don't forget to rate a good Answer....
---------------------------------------------------------
Here should be some cool signature

But there's NOT

LabVIEW 2012-2017
---------------------------------------------------------
Message 8 of 42
(4,781 Views)
u r right the image will become 4132x1500.The value 0-99 are discarded.
Message 9 of 42
(4,773 Views)
Hi muks,
like i understand you only need to count all 255 and create an array of "the result of the count" x 1500. Therefore you can use the initialize array function, with the value you take to fill the "empty fields". Now go through your array and search for 255. If you find it search for the next one and overwrite this part with the current line in the initialized array.

Hope it helps.
Mike
Message 10 of 42
(4,769 Views)